mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-09-11 13:56:58 +03:00
increase test coverage
This commit is contained in:
parent
6da2753b83
commit
e55035c568
@ -138,8 +138,7 @@ impl StatementReconstructor for Unroller<'_> {
|
||||
input.start_value.replace(Some(Value::try_from(&start_lit).unwrap()));
|
||||
input.stop_value.replace(Some(Value::try_from(&stop_lit).unwrap()));
|
||||
}
|
||||
(Literal(_), _) => self.emit_err(LoopUnrollerError::loop_bound_must_be_a_literal(new_stop.span())),
|
||||
(_, _) => self.emit_err(LoopUnrollerError::loop_bound_must_be_a_literal(new_start.span())),
|
||||
_ => unreachable!("Type checking guarantees that the loop bounds are literals."),
|
||||
};
|
||||
|
||||
// Ensure loop bounds are increasing. This cannot be done in the type checker because constant propagation occurs in this pass.
|
||||
@ -174,12 +173,7 @@ impl StatementReconstructor for Unroller<'_> {
|
||||
(Integer(IntegerType::U128), Some(Value::U128(lower_bound, _)), Some(Value::U128(upper_bound, _))) => {
|
||||
lower_bound >= upper_bound
|
||||
}
|
||||
_ => {
|
||||
self.emit_err(LoopUnrollerError::loop_bounds_must_have_same_type_as_loop_variable(
|
||||
input.variable.span(),
|
||||
));
|
||||
false
|
||||
}
|
||||
_ => unreachable!("Type checking guarantees that the loop bounds have same type as loop variable."),
|
||||
} {
|
||||
self.emit_err(LoopUnrollerError::loop_range_decreasing(new_stop.span()));
|
||||
}
|
||||
|
@ -29,19 +29,4 @@ create_messages!(
|
||||
msg: format!("The loop range must be increasing."),
|
||||
help: None,
|
||||
}
|
||||
|
||||
@formatted
|
||||
loop_bound_must_be_a_literal {
|
||||
args: (),
|
||||
msg: format!("Loop bound must be a literal after constant propagation."),
|
||||
help: None,
|
||||
}
|
||||
|
||||
@formatted
|
||||
loop_bounds_must_have_same_type_as_loop_variable {
|
||||
args: (),
|
||||
msg: format!("Loop bounds must be the same type"),
|
||||
help: None,
|
||||
}
|
||||
|
||||
);
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [ETYC0372062]: The left-hand side of a `DefinitionStatement` can only be an identifier or tuple. Note that a tuple must contain at least two elements.\n --> compiler-test:7:9\n |\n 7 | const A: () = ();\n | ^^^^^^^^^^^^^^^^\nError [ETYC0372080]: The value of a const declaration must be a literal\n --> compiler-test:7:9\n |\n 7 | const A: () = ();\n | ^^^^^^^^^^^^^^^^\nError [ETYC0372063]: Unit expressions can only be used in return statements.\n --> compiler-test:7:23\n |\n 7 | const A: () = ();\n | ^^\nError [ETYC0372080]: The value of a const declaration must be a literal\n --> compiler-test:8:9\n |\n 8 | const B: u8 = ((1u8,1u8),1u8);\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nError [ETYC0372023]: Tuples must be explicitly typed in Leo\n --> compiler-test:8:23\n |\n 8 | const B: u8 = ((1u8,1u8),1u8);\n | ^^^^^^^^^^^^^^^\n |\n = The function definition must match the function return statement\n"
|
15
tests/expectations/compiler/constants/loop_bound_fail.out
Normal file
15
tests/expectations/compiler/constants/loop_bound_fail.out
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
outputs:
|
||||
- - initial_symbol_table: c6a4e40ae8f466c3ff6bf5d356d6ba89684438f88015e8ea23ff43eadb662b49
|
||||
type_checked_symbol_table: 1f2f455b3509dd7c93fa6799a0f3f01843aaab11efbc772223dcb5de29ae93f9
|
||||
unrolled_symbol_table: ff911ea4ffadc4a3ac5e7f81af922dfb248befd39a4e178c0b7ba795b30f8080
|
||||
initial_ast: 9b2120a39d6e04dfbaf16a794a6d2e0dc9fd67256210572d85a959c593c6b07c
|
||||
unrolled_ast: 5b36cdd4106acc7a27c70f02f0e2562ba97f86523e06ae2d384b3617f6362460
|
||||
ssa_ast: ae7908bc7fa1b46f457c1bba57871e3a46f2826d1c508c17f4e6cdf21b483307
|
||||
flattened_ast: 1c45e7b12455209eb5a0c8d4f344ad74a592e0a4dafc5e70b5a40a8c70efad24
|
||||
inlined_ast: 1c45e7b12455209eb5a0c8d4f344ad74a592e0a4dafc5e70b5a40a8c70efad24
|
||||
dce_ast: 8bebed7b5a44ab7f63d2c178dd9544cd85f3e062e98f5366097f52aafd05043a
|
||||
bytecode: a5ef8b434b2a8b1939f1d042fd5706c996e0f1905bf2395a0f140cff779ce48a
|
||||
warnings: ""
|
@ -0,0 +1,15 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
outputs:
|
||||
- - initial_symbol_table: c6a4e40ae8f466c3ff6bf5d356d6ba89684438f88015e8ea23ff43eadb662b49
|
||||
type_checked_symbol_table: 1f2f455b3509dd7c93fa6799a0f3f01843aaab11efbc772223dcb5de29ae93f9
|
||||
unrolled_symbol_table: ff911ea4ffadc4a3ac5e7f81af922dfb248befd39a4e178c0b7ba795b30f8080
|
||||
initial_ast: 9b2120a39d6e04dfbaf16a794a6d2e0dc9fd67256210572d85a959c593c6b07c
|
||||
unrolled_ast: 5b36cdd4106acc7a27c70f02f0e2562ba97f86523e06ae2d384b3617f6362460
|
||||
ssa_ast: ae7908bc7fa1b46f457c1bba57871e3a46f2826d1c508c17f4e6cdf21b483307
|
||||
flattened_ast: 1c45e7b12455209eb5a0c8d4f344ad74a592e0a4dafc5e70b5a40a8c70efad24
|
||||
inlined_ast: 1c45e7b12455209eb5a0c8d4f344ad74a592e0a4dafc5e70b5a40a8c70efad24
|
||||
dce_ast: 8bebed7b5a44ab7f63d2c178dd9544cd85f3e062e98f5366097f52aafd05043a
|
||||
bytecode: a5ef8b434b2a8b1939f1d042fd5706c996e0f1905bf2395a0f140cff779ce48a
|
||||
warnings: ""
|
14
tests/tests/compiler/constants/const_type_error_fail.leo
Normal file
14
tests/tests/compiler/constants/const_type_error_fail.leo
Normal file
@ -0,0 +1,14 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
*/
|
||||
|
||||
program test.aleo {
|
||||
const START: u32 = 0u32;
|
||||
transition foo(a: u32, b: u32, flag: bool) -> u32 {
|
||||
const STOP: u32 = 10u32;
|
||||
const A: () = ();
|
||||
const B: u8 = ((1u8,1u8),1u8);
|
||||
return 1u32;
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
*/
|
||||
|
||||
program test.aleo {
|
||||
const START: u32 = 0u32;
|
||||
transition foo(a: u32, b: u32, flag: bool) -> u32 {
|
||||
const STOP: u32 = 10u32;
|
||||
for i: u32 in START..STOP {
|
||||
for j: u32 in START..STOP {
|
||||
let (c,d): (u32,u32) = (1u32, 1u32);
|
||||
}
|
||||
}
|
||||
return 1u32;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user