leo/disabled_tests/compiler/mutability/swap.leo

22 lines
440 B
Plaintext
Raw Normal View History

2021-05-03 16:47:33 +03:00
/*
namespace: Compile
expectation: Pass
2021-05-05 18:29:44 +03:00
input_file: input/dummy.in
2021-05-03 16:47:33 +03:00
*/
// Swap two elements of an array.
2021-03-19 18:30:24 +03:00
function swap(a: [u32; 2], const i: u32, const j: u32) -> [u32; 2] {
2021-05-06 14:27:42 +03:00
let t = a[i];
a[i] = a[j];
a[j] = t;
return a;
}
2021-05-03 16:47:33 +03:00
function main(arr: [u32; 2]) -> bool {
const expected: [u32; 2] = [1, 0];
2021-05-06 14:27:42 +03:00
let actual = swap(arr, 0, 1);
2021-05-03 16:47:33 +03:00
// Do swap.
return expected[0] == actual[0] && expected[1] == actual[1];
2021-05-05 18:29:44 +03:00
}