//! > Test strings.
//! > test_runner_name
test_function_lowering(expect_diagnostics: false)
//! > 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(expect_diagnostics: false)
//! > 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(expect_diagnostics: false)
//! > 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(expect_diagnostics: false)
//! > 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(expect_diagnostics: false)
//! > 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(expect_diagnostics: false)
//! > function
fn foo() -> ByteArray {
let x = "hello";
x + " world"
}
//! > function_name
foo
//! > module_code
//! > semantic_diagnostics
//! > lowering_diagnostics
//! > lowering_flat
Parameters: v0: core::RangeCheck, v1: core::gas::GasBuiltin
blk0 (root):
Statements:
(v2: core::array::Array::<core::bytes_31::bytes31>) <- core::array::array_new::<core::bytes_31::bytes31>()
(v3: 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>()
(v5: core::felt252) <- 448378203247
(v6: core::integer::u32) <- 5
(v7: core::byte_array::ByteArray) <- struct_construct(v2, v5, v6)
(v8: core::byte_array::ByteArray, v9: @core::byte_array::ByteArray) <- snapshot(v7)
(v10: @core::array::Array::<core::bytes_31::bytes31>, v11: @core::felt252, v12: @core::integer::u32) <- struct_destructure(v9)
(v13: core::array::Span::<core::bytes_31::bytes31>) <- struct_construct(v10)
(v14: core::RangeCheck, v15: core::gas::GasBuiltin, v16: core::panics::PanicResult::<(core::array::Span::<core::bytes_31::bytes31>, core::array::Array::<core::bytes_31::bytes31>, ())>) <- core::array::ArrayTCloneImpl::clone[expr14](v0, v1, v13, v4)
End:
Match(match_enum(v16) {
PanicResult::Ok(v17) => blk1,
PanicResult::Err(v18) => blk4,
})
blk1:
Statements:
(v19: core::felt252) <- 35697342966884
(v20: core::integer::u32) <- 6
(v21: core::byte_array::ByteArray) <- struct_construct(v3, v19, v20)
(v22: core::byte_array::ByteArray, v23: @core::byte_array::ByteArray) <- snapshot(v21)
(v24: core::array::Span::<core::bytes_31::bytes31>, v25: core::array::Array::<core::bytes_31::bytes31>, v26: ()) <- struct_destructure(v17)
(v27: @core::array::Array::<core::bytes_31::bytes31>, v28: @core::felt252, v29: @core::integer::u32) <- struct_destructure(v9)
(v30: core::felt252) <- desnap(v28)
(v31: @core::array::Array::<core::bytes_31::bytes31>, v32: @core::felt252, v33: @core::integer::u32) <- struct_destructure(v9)
(v34: core::integer::u32) <- desnap(v33)
(v35: core::byte_array::ByteArray) <- struct_construct(v25, v30, v34)
(v36: core::RangeCheck, v37: core::gas::GasBuiltin, v38: core::panics::PanicResult::<(core::byte_array::ByteArray, ())>) <- core::byte_array::ByteArrayImpl::append(v14, v15, v35, v23)
End:
Match(match_enum(v38) {
PanicResult::Ok(v39) => blk2,
PanicResult::Err(v40) => blk3,
})
blk2:
Statements:
(v41: core::byte_array::ByteArray, v42: ()) <- struct_destructure(v39)
(v43: (core::byte_array::ByteArray,)) <- struct_construct(v41)
(v44: core::panics::PanicResult::<(core::byte_array::ByteArray,)>) <- PanicResult::Ok(v43)
End:
Return(v36, v37, v44)
blk3:
Statements:
(v45: core::panics::PanicResult::<(core::byte_array::ByteArray,)>) <- PanicResult::Err(v40)
End:
Return(v36, v37, v45)
blk4:
Statements:
(v46: core::panics::PanicResult::<(core::byte_array::ByteArray,)>) <- PanicResult::Err(v18)
End:
Return(v14, v15, v46)