mirror of
https://github.com/AleoHQ/leo.git
synced 2024-11-10 10:05:56 +03:00
stabilize scalar tests
This commit is contained in:
parent
86219c0044
commit
0a34115ef7
@ -629,8 +629,8 @@ impl<'a> ExpressionVisitor<'a> for TypeChecker<'a> {
|
||||
self.visit_expression(&input.receiver, destination)
|
||||
}
|
||||
UnaryOperation::SquareRoot => {
|
||||
// Only field or scalar type.
|
||||
self.assert_field_scalar_type(destination, input.span());
|
||||
// Only field type.
|
||||
self.assert_field_type(destination, input.span());
|
||||
self.visit_expression(&input.receiver, destination)
|
||||
}
|
||||
}
|
||||
|
@ -216,16 +216,6 @@ impl<'a> TypeChecker<'a> {
|
||||
)
|
||||
}
|
||||
|
||||
/// Emits an error to the handler if the given type is not a field or scalar.
|
||||
pub(crate) fn assert_field_scalar_type(&self, type_: &Option<Type>, span: Span) {
|
||||
self.check_type(
|
||||
|type_: &Type| FIELD_TYPE.eq(type_) | SCALAR_TYPE.eq(type_),
|
||||
format!("{}, {}", FIELD_TYPE, SCALAR_TYPE),
|
||||
type_,
|
||||
span,
|
||||
)
|
||||
}
|
||||
|
||||
/// Emits an error to the handler if the given type is not a field, group, or integer.
|
||||
pub(crate) fn assert_field_group_int_type(&self, type_: &Option<Type>, span: Span) {
|
||||
self.check_type(
|
||||
|
@ -1,10 +0,0 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
input_file:
|
||||
- inputs/scalars.in
|
||||
*/
|
||||
|
||||
function main(a: scalar, b: scalar, c: scalar) -> bool {
|
||||
return a / b != c;
|
||||
}
|
10
tests/compiler/scalar/div_fail.leo
Normal file
10
tests/compiler/scalar/div_fail.leo
Normal file
@ -0,0 +1,10 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
input_file:
|
||||
- inputs/scalars.in
|
||||
*/
|
||||
|
||||
function main(a: scalar, b: scalar) -> scalar {
|
||||
return a / b; // division not supported for scalar types.
|
||||
}
|
@ -6,9 +6,6 @@ input_file:
|
||||
*/
|
||||
|
||||
function main(a: scalar, b: scalar) -> bool {
|
||||
// unary
|
||||
let i: scalar = a.square_root();
|
||||
|
||||
// binary
|
||||
let j: scalar = a.add(b);
|
||||
let o: bool = a.eq(b);
|
||||
@ -16,8 +13,8 @@ function main(a: scalar, b: scalar) -> bool {
|
||||
let q: bool = a.gt(b);
|
||||
let r: bool = a.lte(b);
|
||||
let s: bool = a.lt(b);
|
||||
let t: group = 2group.mul(b);
|
||||
let u: group = a.mul(2group);
|
||||
// let t: group = 2group.mul(b);
|
||||
// let u: group = a.mul(2group);
|
||||
let w: bool = a.neq(b);
|
||||
|
||||
return a == b;
|
||||
|
10
tests/compiler/scalar/square_root_fail.leo
Normal file
10
tests/compiler/scalar/square_root_fail.leo
Normal file
@ -0,0 +1,10 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
input_file:
|
||||
- inputs/scalars.in
|
||||
*/
|
||||
|
||||
function main(a: scalar) -> scalar {
|
||||
return a.square_root(); // square root not supported for scalar types.
|
||||
}
|
9
tests/expectations/compiler/scalar/add.out
Normal file
9
tests/expectations/compiler/scalar/add.out
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
outputs:
|
||||
- output:
|
||||
- initial_input_ast: c528268c53f01e78fbbc8af3ed5e0dc1d4e9b9f28644c597167971edef764cf0
|
||||
initial_ast: 267628fed05800b7d1b0d3218f30e6d614b38119d94fcf30be64e1e74cb68717
|
||||
unrolled_ast: 267628fed05800b7d1b0d3218f30e6d614b38119d94fcf30be64e1e74cb68717
|
||||
ssa_ast: b2e6c173eb839a726e82f149719c2d3f560e685482730ff066ec6371a67a50f7
|
9
tests/expectations/compiler/scalar/cmp.out
Normal file
9
tests/expectations/compiler/scalar/cmp.out
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
outputs:
|
||||
- output:
|
||||
- initial_input_ast: 8b51ce00d3448cda6f763ac1fbc6d14a2588dc0bc0d24eb423b5f417029b28c5
|
||||
initial_ast: 78ad22f7a7591585c256c097527f6697371a0788e2a4f298ba78dfa14bec5716
|
||||
unrolled_ast: 78ad22f7a7591585c256c097527f6697371a0788e2a4f298ba78dfa14bec5716
|
||||
ssa_ast: 4b2a40d14e26818ea4bd82b2400265bbe633e243b4d7d62be4093a2bb6a68f66
|
5
tests/expectations/compiler/scalar/div_fail.out
Normal file
5
tests/expectations/compiler/scalar/div_fail.out
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [ETYC0372007]: Expected one type from `field, i8, i16, i32, i64, i128, u8, u16, u32, u64, u128`, but got `scalar`\n --> compiler-test:4:12\n |\n 4 | return a / b; // division not supported for scalar types.\n | ^^^^^\n"
|
9
tests/expectations/compiler/scalar/eq.out
Normal file
9
tests/expectations/compiler/scalar/eq.out
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
outputs:
|
||||
- output:
|
||||
- initial_input_ast: fbb9f33bc5cf7fd11341e6dc1d12d4899274f3bee34dd64590ffd3c9438a61a5
|
||||
initial_ast: 8289ba8d30365026c4e1b2fdef5afded1ca8c748dbe8051a96d6ecad4a6fe2b2
|
||||
unrolled_ast: 8289ba8d30365026c4e1b2fdef5afded1ca8c748dbe8051a96d6ecad4a6fe2b2
|
||||
ssa_ast: 85863634a5c310ad76a098e3a2e9419d3d5d46fc675c859d253343471899176a
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [EPAR0370005]: expected -> -- found '{'\n --> compiler-test:3:17\n |\n 3 | function main() {\n | ^"
|
9
tests/expectations/compiler/scalar/operator_methods.out
Normal file
9
tests/expectations/compiler/scalar/operator_methods.out
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
outputs:
|
||||
- output:
|
||||
- initial_input_ast: d7a45ca3c65b0e933098d6a2be13eebaeac9395e7c0461be10c5fcf1e99a7e5e
|
||||
initial_ast: da81d8fd30bf591686b8991f5f0edda86155bac3d0b5531a336fe90372d82ee1
|
||||
unrolled_ast: da81d8fd30bf591686b8991f5f0edda86155bac3d0b5531a336fe90372d82ee1
|
||||
ssa_ast: 1d1b56f3e69520219eaeda8d96977a64f915ba554e721c5f6cc89ff71a170546
|
9
tests/expectations/compiler/scalar/scalar.out
Normal file
9
tests/expectations/compiler/scalar/scalar.out
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
outputs:
|
||||
- output:
|
||||
- initial_input_ast: 28228b87fcb43040ca2c4a6c9e6539642323a9f64d837a6de7f579b17ceb1da4
|
||||
initial_ast: e11179e20be602466a0d59025b95a169b431b190d4cc6cb2bc80287e7429bf9b
|
||||
unrolled_ast: e11179e20be602466a0d59025b95a169b431b190d4cc6cb2bc80287e7429bf9b
|
||||
ssa_ast: f7f43114a0adce0fb246b06465b583cab83745fa54f09a2264d3dcfbd803ac51
|
5
tests/expectations/compiler/scalar/square_root_fail.out
Normal file
5
tests/expectations/compiler/scalar/square_root_fail.out
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [ETYC0372007]: Expected one type from `field`, but got `scalar`\n --> compiler-test:4:12\n |\n 4 | return a.square_root(); // square root not supported for scalar types.\n | ^^^^^^^^^^^^^^^\n"
|
9
tests/expectations/compiler/scalar/ternary.out
Normal file
9
tests/expectations/compiler/scalar/ternary.out
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
outputs:
|
||||
- output:
|
||||
- initial_input_ast: fbb9f33bc5cf7fd11341e6dc1d12d4899274f3bee34dd64590ffd3c9438a61a5
|
||||
initial_ast: fbc9f38d923601aa2e14979cb36a6f6a4d41feea94a4cf381c2bf14060c3e457
|
||||
unrolled_ast: fbc9f38d923601aa2e14979cb36a6f6a4d41feea94a4cf381c2bf14060c3e457
|
||||
ssa_ast: 8faf6baa2ff1cb8b7e20bbec6022306ca75ddd034644715c3402fa9f002acb56
|
@ -5,6 +5,6 @@ input_file:
|
||||
- inputs/scalars.in
|
||||
*/
|
||||
|
||||
function main(a: scalar, b: scalar, c: scalar) -> bool {
|
||||
function main(a: scalar, b: group, c: scalar) -> bool {
|
||||
return a * b == c;
|
||||
}
|
Loading…
Reference in New Issue
Block a user