fix input group value and add test

This commit is contained in:
collin 2020-08-13 11:37:48 -07:00
parent 24a679474e
commit d1eddcf4db
5 changed files with 35 additions and 2 deletions

View File

@ -0,0 +1,2 @@
[main]
a: group = (7374112779530666882856915975292384652154477718021969292781165691637980424078, 3435195339177955418892975564890903138308061187980579490487898366607011481796)group;

View File

@ -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");

View File

@ -0,0 +1,3 @@
function main(a: group) {
let b = a;
}

View File

@ -8,8 +8,10 @@ protected_name = {
| "const"
| "else"
| "false"
| "function"
| type_field
| "for"
| "function"
| type_group
| "if"
| "import"
| "in"

View File

@ -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> {