From cb6fcceb7987067aff69b063ed25f01f24b4b5da Mon Sep 17 00:00:00 2001 From: Erin Date: Tue, 22 Feb 2022 22:49:56 +0100 Subject: [PATCH] Fixed tests and examples --- able-script-test/by-arity-chain.able | 28 ++++++++++++------------- able-script-test/carts.able | 6 +++--- able-script-test/functio.able | 2 +- able-script-test/hello-world.able | 2 +- able-script-test/melo-hello.able | 2 +- able-script-test/pass-by-reference.able | 14 ++++++------- ablescript/src/interpret.rs | 4 ++-- ablescript/src/parser.rs | 12 +++++------ 8 files changed, 35 insertions(+), 35 deletions(-) diff --git a/able-script-test/by-arity-chain.able b/able-script-test/by-arity-chain.able index 2dca191c..8e1665bc 100644 --- a/able-script-test/by-arity-chain.able +++ b/able-script-test/by-arity-chain.able @@ -1,44 +1,44 @@ functio arity_0() { - "this function has arity 0" print; + /*this function has arity 0*/ print; } functio arity_1(arg1) { - "this function has arity 1" print; + /*this function has arity 1*/ print; arg1 print; } functio arity_2(arg1, arg2) { - "this function has arity 2" print; + /*this function has arity 2*/ print; arg1 print; arg2 print; } functio arity_3(arg1, arg2, arg3) { - "this function has arity 3" print; + /*this function has arity 3*/ print; arg1 print; arg2 print; arg3 print; } owo arity_0(); -owo arity_1("foo"); -owo arity_2("foo", "bar"); -owo arity_3("foo", "bar", "baz"); +owo arity_1(/*foo*/); +owo arity_2(/*foo*/, /*bar*/); +owo arity_3(/*foo*/, /*bar*/, /*baz*/); var i1 = arity_0 * arity_1; -i1("second"); +i1(/*second*/); -"----" print; +/*----*/ print; var i2 = arity_1 * arity_0; -i2("first"); +i2(/*first*/); -"----" print; +/*----*/ print; var ifancy = arity_3 * arity_3; -ifancy("left1", "right1", "left2", "right2", "left3", "right3"); +ifancy(/*left1*/, /*right1*/, /*left2*/, /*right2*/, /*left3*/, /*right3*/); -"----" print; +/*---*/" print; var another = arity_0 * arity_3; -another("right1", "right2", "right3"); +another(/*right1*/, /*right2*/, /*right3*/); diff --git a/able-script-test/carts.able b/able-script-test/carts.able index b12ef8dc..94f102de 100644 --- a/able-script-test/carts.able +++ b/able-script-test/carts.able @@ -1,8 +1,8 @@ functio helloable() { - "Hello, Able!" print; + "ยด/*Hello, Able!*/ print; } -var cart = ["able" <= 42, helloable <= "hello"]; +var cart = [/*able*/ <= 42, helloable <= /*hello*/]; cart[42] print; -cart["hello"](); +cart[/*hello*/](); diff --git a/able-script-test/functio.able b/able-script-test/functio.able index b31584cc..5f2635b6 100644 --- a/able-script-test/functio.able +++ b/able-script-test/functio.able @@ -1,4 +1,4 @@ functio hello(words){ words print; } -hello("wonk"); +hello(/*wonk*/); diff --git a/able-script-test/hello-world.able b/able-script-test/hello-world.able index d32b8b8a..cf2fc477 100644 --- a/able-script-test/hello-world.able +++ b/able-script-test/hello-world.able @@ -1,2 +1,2 @@ -var hello = "world"; +var hello = /*world*/; hello print; diff --git a/able-script-test/melo-hello.able b/able-script-test/melo-hello.able index e8fc7b93..2e6279d6 100644 --- a/able-script-test/melo-hello.able +++ b/able-script-test/melo-hello.able @@ -1,3 +1,3 @@ -var hi = "wonk"; +var hi = /*wonk*/; melo hi; hi print; owo Should error out diff --git a/able-script-test/pass-by-reference.able b/able-script-test/pass-by-reference.able index 25c77a7c..cf51edbf 100644 --- a/able-script-test/pass-by-reference.able +++ b/able-script-test/pass-by-reference.able @@ -7,17 +7,17 @@ functio swap(left, right) { right = tmp; } -var foo = "hello"; -var bar = "world"; +var foo = /*hello*/; +var bar = /*world*/; swap(foo, bar); -if (foo != "world") { - "FAILED" print; - "foo should be 'world', is actually:" print; +if (foo != /*world*/) { + /*FAILED*/ print; + /*foo should be 'world', is actually:*/ print; foo print; } -if (foo == "world") { - "OK" print; +if (foo == /*world*/) { + /*OK*/ print; } diff --git a/ablescript/src/interpret.rs b/ablescript/src/interpret.rs index ba9191f6..0d0b1499 100644 --- a/ablescript/src/interpret.rs +++ b/ablescript/src/interpret.rs @@ -673,7 +673,7 @@ mod tests { span: 1..1 }) .unwrap(), - Value::Int(-2147483648) + Value::Int(-9223372036854775808) ); // And the same for divide by zero. @@ -728,7 +728,7 @@ mod tests { ); // Assigning an existing variable. - eval(&mut env, "foo = \"hi\";").unwrap(); + eval(&mut env, "foo = /*hi*/;").unwrap(); assert_eq!( env.get_var(&Ident { ident: "foo".to_owned(), diff --git a/ablescript/src/parser.rs b/ablescript/src/parser.rs index 7597e794..d9612f35 100644 --- a/ablescript/src/parser.rs +++ b/ablescript/src/parser.rs @@ -579,7 +579,7 @@ mod tests { #[test] fn simple_math() { - let code = r#"1 * (a + 3) / 666 print;"#; + let code = "1 * (a + 3) / 666 print;"; let expected = &[Stmt { kind: StmtKind::Print(Expr { kind: ExprKind::BinOp { @@ -624,7 +624,7 @@ mod tests { #[test] fn variable_declaration() { - let code = r#"var a = 42;"#; + let code = "var a = 42;"; let expected = &[Stmt { kind: StmtKind::Var { ident: Ident { @@ -645,7 +645,7 @@ mod tests { #[test] fn if_flow() { - let code = r#"if (a == always) { "Buy Able products!" print; }"#; + let code = "if (a == always) { /*Buy Able products!*/ print; }"; let expected = &[Stmt { kind: StmtKind::If { cond: Expr { @@ -681,7 +681,7 @@ mod tests { #[test] fn tdark() { - let code = r#"T-Dark { var lang = "lang" + lang; }"#; + let code = "T-Dark { var lang = /*lang*/ + lang; }"; let expected = &[Stmt { kind: StmtKind::Var { ident: Ident { @@ -712,7 +712,7 @@ mod tests { #[test] fn cart_construction() { - let code = r#"["able" <= 1, "script" <= 3 - 1] print;"#; + let code = "[/*able*/ <= 1, /*script*/ <= 3 - 1] print;"; let expected = &[Stmt { kind: StmtKind::Print(Expr { kind: ExprKind::Cart(vec![ @@ -758,7 +758,7 @@ mod tests { #[test] fn cart_index() { - let code = r#"["able" <= "ablecorp"]["ablecorp"] print;"#; + let code = "[/*able*/ <= /*ablecorp*/][/*ablecorp*/] print;"; let expected = &[Stmt { kind: StmtKind::Print(Expr { kind: ExprKind::Index {