//! > Test strings.

//! > test_runner_name
test_function_lowering

//! > function
fn foo() -> ByteArray {
    let x = "hello";
    x
}

//! > function_name
foo

//! > module_code

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters:
blk0 (root):
Statements:
  (v0: core::array::Array::<core::bytes_31::bytes31>) <- core::array::array_new::<core::bytes_31::bytes31>()
  (v1: core::felt252) <- 448378203247
  (v2: core::integer::u32) <- 5
  (v3: core::byte_array::ByteArray) <- struct_construct(v0, v1, v2)
End:
  Return(v3)

//! > ==========================================================================

//! > Test string of length exactly 31.

//! > test_runner_name
test_function_lowering

//! > function
fn foo() -> ByteArray {
    "This is a string of length 31!!"
}

//! > function_name
foo

//! > module_code

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters:
blk0 (root):
Statements:
  (v0: core::array::Array::<core::bytes_31::bytes31>) <- core::array::array_new::<core::bytes_31::bytes31>()
  (v1: core::bytes_31::bytes31) <- 149135777980097582634002139252429040475994949483886278789328970947115426081
  (v2: core::array::Array::<core::bytes_31::bytes31>) <- core::array::array_append::<core::bytes_31::bytes31>(v0, v1)
  (v3: core::felt252) <- 0
  (v4: core::integer::u32) <- 0
  (v5: core::byte_array::ByteArray) <- struct_construct(v2, v3, v4)
End:
  Return(v5)

//! > ==========================================================================

//! > Test string longer than 31.

//! > test_runner_name
test_function_lowering

//! > function
fn foo() -> ByteArray {
    "This is a string longer than 31 characters."
}

//! > function_name
foo

//! > module_code

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters:
blk0 (root):
Statements:
  (v0: core::array::Array::<core::bytes_31::bytes31>) <- core::array::array_new::<core::bytes_31::bytes31>()
  (v1: core::bytes_31::bytes31) <- 149135777980097582634002139252429040475994889373844716668334467060223456049
  (v2: core::array::Array::<core::bytes_31::bytes31>) <- core::array::array_append::<core::bytes_31::bytes31>(v0, v1)
  (v3: core::felt252) <- 10023696894115262225051710254
  (v4: core::integer::u32) <- 12
  (v5: core::byte_array::ByteArray) <- struct_construct(v2, v3, v4)
End:
  Return(v5)

//! > ==========================================================================

//! > Test string longer than 62.

//! > test_runner_name
test_function_lowering

//! > function
fn foo() -> ByteArray {
    "This is a very very long string. It is longer than 62 characters!"
}

//! > function_name
foo

//! > module_code

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters:
blk0 (root):
Statements:
  (v0: core::array::Array::<core::bytes_31::bytes31>) <- core::array::array_new::<core::bytes_31::bytes31>()
  (v1: core::bytes_31::bytes31) <- 149135777980097582634002143551300458181193150334766401759981576101506412135
  (v2: core::array::Array::<core::bytes_31::bytes31>) <- core::array::array_append::<core::bytes_31::bytes31>(v0, v1)
  (v3: core::bytes_31::bytes31) <- 81497801168569000366308429866993893991598961463881166117681206773816718437
  (v4: core::array::Array::<core::bytes_31::bytes31>) <- core::array::array_append::<core::bytes_31::bytes31>(v2, v3)
  (v5: core::felt252) <- 7500577
  (v6: core::integer::u32) <- 3
  (v7: core::byte_array::ByteArray) <- struct_construct(v4, v5, v6)
End:
  Return(v7)

//! > ==========================================================================

//! > Test empty string.

//! > test_runner_name
test_function_lowering

//! > function
fn foo() -> ByteArray {
    let y = "";
    y
}

//! > function_name
foo

//! > module_code

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters:
blk0 (root):
Statements:
  (v0: core::array::Array::<core::bytes_31::bytes31>) <- core::array::array_new::<core::bytes_31::bytes31>()
  (v1: core::felt252) <- 0
  (v2: core::integer::u32) <- 0
  (v3: core::byte_array::ByteArray) <- struct_construct(v0, v1, v2)
End:
  Return(v3)

//! > ==========================================================================

//! > Test string literal in an expression.

//! > test_runner_name
test_function_lowering

//! > function
fn foo() -> ByteArray {
    let x = "hello";
    x + " world"
}

//! > function_name
foo

//! > module_code

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_flat
Parameters: v49: core::RangeCheck, v50: core::gas::GasBuiltin
blk0 (root):
Statements:
  (v0: core::array::Array::<core::bytes_31::bytes31>) <- core::array::array_new::<core::bytes_31::bytes31>()
  (v4: core::array::Array::<core::bytes_31::bytes31>) <- core::array::array_new::<core::bytes_31::bytes31>()
  (v16: core::array::Array::<core::bytes_31::bytes31>) <- core::array::array_new::<core::bytes_31::bytes31>()
  (v1: core::felt252) <- 448378203247
  (v2: core::integer::u32) <- 5
  (v3: core::byte_array::ByteArray) <- struct_construct(v0, v1, v2)
  (v17: core::byte_array::ByteArray, v18: @core::byte_array::ByteArray) <- snapshot(v3)
  (v19: @core::array::Array::<core::bytes_31::bytes31>, v20: @core::felt252, v21: @core::integer::u32) <- struct_destructure(v18)
  (v22: core::array::Span::<core::bytes_31::bytes31>) <- struct_construct(v19)
  (v51: core::RangeCheck, v52: core::gas::GasBuiltin, v23: core::panics::PanicResult::<(core::array::Span::<core::bytes_31::bytes31>, core::array::Array::<core::bytes_31::bytes31>, ())>) <- core::array::ArrayTCloneImpl::clone[expr14](v49, v50, v22, v16)
End:
  Match(match_enum(v23) {
    PanicResult::Ok(v24) => blk1,
    PanicResult::Err(v25) => blk4,
  })

blk1:
Statements:
  (v5: core::felt252) <- 35697342966884
  (v6: core::integer::u32) <- 6
  (v7: core::byte_array::ByteArray) <- struct_construct(v4, v5, v6)
  (v26: core::byte_array::ByteArray, v27: @core::byte_array::ByteArray) <- snapshot(v7)
  (v28: core::array::Span::<core::bytes_31::bytes31>, v29: core::array::Array::<core::bytes_31::bytes31>, v30: ()) <- struct_destructure(v24)
  (v31: @core::array::Array::<core::bytes_31::bytes31>, v32: @core::felt252, v33: @core::integer::u32) <- struct_destructure(v18)
  (v34: core::felt252) <- desnap(v32)
  (v35: @core::array::Array::<core::bytes_31::bytes31>, v36: @core::felt252, v37: @core::integer::u32) <- struct_destructure(v18)
  (v38: core::integer::u32) <- desnap(v37)
  (v39: core::byte_array::ByteArray) <- struct_construct(v29, v34, v38)
  (v53: core::RangeCheck, v54: core::gas::GasBuiltin, v40: core::panics::PanicResult::<(core::byte_array::ByteArray, ())>) <- core::byte_array::ByteArrayImpl::append(v51, v52, v39, v27)
End:
  Match(match_enum(v40) {
    PanicResult::Ok(v41) => blk2,
    PanicResult::Err(v42) => blk3,
  })

blk2:
Statements:
  (v43: core::byte_array::ByteArray, v44: ()) <- struct_destructure(v41)
  (v45: (core::byte_array::ByteArray,)) <- struct_construct(v43)
  (v46: core::panics::PanicResult::<(core::byte_array::ByteArray,)>) <- PanicResult::Ok(v45)
End:
  Return(v53, v54, v46)

blk3:
Statements:
  (v47: core::panics::PanicResult::<(core::byte_array::ByteArray,)>) <- PanicResult::Err(v42)
End:
  Return(v53, v54, v47)

blk4:
Statements:
  (v48: core::panics::PanicResult::<(core::byte_array::ByteArray,)>) <- PanicResult::Err(v25)
End:
  Return(v51, v52, v48)
