mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-23 23:23:50 +03:00
fix input group value and add test
This commit is contained in:
parent
24a679474e
commit
d1eddcf4db
2
compiler/tests/group/input/point.in
Normal file
2
compiler/tests/group/input/point.in
Normal file
@ -0,0 +1,2 @@
|
||||
[main]
|
||||
a: group = (7374112779530666882856915975292384652154477718021969292781165691637980424078, 3435195339177955418892975564890903138308061187980579490487898366607011481796)group;
|
@ -44,6 +44,16 @@ fn test_point() {
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_point_input() {
|
||||
let program_bytes = include_bytes!("point_input.leo");
|
||||
let input_bytes = include_bytes!("input/point.in");
|
||||
|
||||
let program = parse_program_with_input(program_bytes, input_bytes).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_input() {
|
||||
let program_bytes = include_bytes!("input.leo");
|
||||
|
3
compiler/tests/group/point_input.leo
Normal file
3
compiler/tests/group/point_input.leo
Normal file
@ -0,0 +1,3 @@
|
||||
function main(a: group) {
|
||||
let b = a;
|
||||
}
|
@ -8,8 +8,10 @@ protected_name = {
|
||||
| "const"
|
||||
| "else"
|
||||
| "false"
|
||||
| "function"
|
||||
| type_field
|
||||
| "for"
|
||||
| "function"
|
||||
| type_group
|
||||
| "if"
|
||||
| "import"
|
||||
| "in"
|
||||
|
@ -7,7 +7,7 @@ use std::fmt;
|
||||
#[derive(Clone, Debug, FromPest, PartialEq, Eq)]
|
||||
#[pest_ast(rule(Rule::value_group))]
|
||||
pub struct GroupValue<'ast> {
|
||||
pub value: GroupTuple<'ast>,
|
||||
pub value: GroupRepresentation<'ast>,
|
||||
pub _type: GroupType,
|
||||
#[pest_ast(outer())]
|
||||
pub span: Span<'ast>,
|
||||
@ -19,6 +19,22 @@ impl<'ast> fmt::Display for GroupValue<'ast> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, FromPest, PartialEq, Eq)]
|
||||
#[pest_ast(rule(Rule::group_single_or_tuple))]
|
||||
pub enum GroupRepresentation<'ast> {
|
||||
Single(NumberValue<'ast>),
|
||||
Tuple(GroupTuple<'ast>),
|
||||
}
|
||||
|
||||
impl<'ast> fmt::Display for GroupRepresentation<'ast> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
GroupRepresentation::Single(number) => write!(f, "{}", number),
|
||||
GroupRepresentation::Tuple(tuple) => write!(f, "{}", tuple),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, FromPest, PartialEq, Eq)]
|
||||
#[pest_ast(rule(Rule::group_tuple))]
|
||||
pub struct GroupTuple<'ast> {
|
||||
|
Loading…
Reference in New Issue
Block a user