Skip to content

Commit

Permalink
test(eval): change up diagnostics printing
Browse files Browse the repository at this point in the history
  • Loading branch information
jamestrew committed Dec 23, 2023
1 parent 27eaf17 commit 9bddfc0
Show file tree
Hide file tree
Showing 60 changed files with 162 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ Environment {
========================

[
Error(ExpectedTokenNotFound("]"), (0,12)->(0,24)),
"SyntaxError: Expected ']' not found. (0,12)->(0,24)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ Environment {
========================

[
Error(UnknownIdentifier("foo"), (0,12)->(0,15)),
"NameError: 'foo' is not defined. (0,12)->(0,15)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ Environment {
========================

[
Warning(UnusedExpression, (0,0)->(0,1)),
Error(BadPrefixType("bool"), (0,1)->(0,5)),
"Expression value is unused (0,0)->(0,1)",
"TypeError: bad operand type for unary +: 'bool'. (0,1)->(0,5)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ Environment {
========================

[
Error(BadPrefixType("str"), (0,9)->(0,14)),
"TypeError: bad operand type for unary +: 'str'. (0,9)->(0,14)",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
source: src/eval/test.rs
description: "\nlet x = \"foo\" + 1;\nlet x = true + 1;\nlet x = \"foo\" + true;\n"
expression: "format!(\"{:#?}\\n\\n========================\\n\\n{:#?}\", env, diags)"
---
Environment {
store: [
(
"x",
Spanned(Unknown, (3,4)->(3,5)),
),
],
refs: [
Spanned("x", "(1,4)->(1,5)"),
Spanned("x", "(2,4)->(2,5)"),
Spanned("x", "(3,4)->(3,5)"),
],
scope_range: "(0,0)->(3,21)",
parent_range: None,
children: [],
}

========================

[
"TypeError: <str> + <int> (1,14)->(1,15)",
"TypeError: <bool> + <int> (2,13)->(2,14)",
"TypeError: <str> + <bool> (3,14)->(3,15)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ Environment {
========================

[
Error(UnexpectedToken("@"), (0,0)->(0,1)),
"SyntaxError: Unexpected '@'. (0,0)->(0,1)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ Environment {
========================

[
Error(BadIndex("int"), (0,8)->(0,9)),
"TypeError: 'int' object is not subscriptable. (0,8)->(0,9)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ Environment {
========================

[
Error(UnknownOperator("bool", "bool", "+"), (0,13)->(0,14)),
"TypeError: <bool> + <bool> (0,13)->(0,14)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ Environment {
========================

[
Error(ExpectedTokenNotFound(";"), (0,13)->(0,14)),
"SyntaxError: Expected ';' not found. (0,13)->(0,14)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ Environment {
========================

[
Error(UnknownOperator("bool", "bool", "/"), (0,13)->(0,14)),
"TypeError: <bool> / <bool> (0,13)->(0,14)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ Environment {
========================

[
Error(UnknownOperator("bool", "bool", ">"), (0,13)->(0,14)),
"TypeError: <bool> > <bool> (0,13)->(0,14)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ Environment {
========================

[
Error(UnknownOperator("bool", "bool", "<"), (0,13)->(0,14)),
"TypeError: <bool> < <bool> (0,13)->(0,14)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ Environment {
========================

[
Error(UnknownOperator("bool", "bool", "-"), (0,13)->(0,14)),
"TypeError: <bool> - <bool> (0,13)->(0,14)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ Environment {
========================

[
Error(UnknownOperator("bool", "bool", "*"), (0,13)->(0,14)),
"TypeError: <bool> * <bool> (0,13)->(0,14)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ Environment {
========================

[
Error(GenericTypeError("unable to get the first of 'int'"), (0,13)->(0,14)),
"TypeError: unable to get the first of 'int' (0,13)->(0,14)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ Environment {
========================

[
Error(MismatchArgs(1, 0), (0,13)->(0,14)),
"TypeError: mismatched arg and param count. Expected 1, got 0. (0,13)->(0,14)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ Environment {
========================

[
Error(MismatchArgs(1, 2), (0,13)->(0,14)),
"TypeError: mismatched arg and param count. Expected 1, got 2. (0,13)->(0,14)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ Environment {
========================

[
Error(GenericTypeError("unable to get the last of 'int'"), (0,12)->(0,13)),
"TypeError: unable to get the last of 'int' (0,12)->(0,13)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ Environment {
========================

[
Error(MismatchArgs(1, 0), (0,12)->(0,13)),
"TypeError: mismatched arg and param count. Expected 1, got 0. (0,12)->(0,13)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ Environment {
========================

[
Error(MismatchArgs(1, 2), (0,12)->(0,13)),
"TypeError: mismatched arg and param count. Expected 1, got 2. (0,12)->(0,13)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ Environment {
========================

[
Error(GenericTypeError("unable to get the len of 'int'"), (0,11)->(0,12)),
"TypeError: unable to get the len of 'int' (0,11)->(0,12)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ Environment {
========================

[
Error(MismatchArgs(1, 0), (0,11)->(0,12)),
"TypeError: mismatched arg and param count. Expected 1, got 0. (0,11)->(0,12)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ Environment {
========================

[
Error(MismatchArgs(1, 2), (0,11)->(0,12)),
"TypeError: mismatched arg and param count. Expected 1, got 2. (0,11)->(0,12)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ Environment {
========================

[
Error(GenericTypeError("unable to push value into 'str'"), (0,12)->(0,13)),
"TypeError: unable to push value into 'str' (0,12)->(0,13)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ Environment {
========================

[
Error(MismatchArgs(2, 1), (0,12)->(0,13)),
"TypeError: mismatched arg and param count. Expected 2, got 1. (0,12)->(0,13)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ Environment {
========================

[
Error(GenericTypeError("unable to get the rest of 'int'"), (0,12)->(0,13)),
"TypeError: unable to get the rest of 'int' (0,12)->(0,13)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ Environment {
========================

[
Error(MismatchArgs(1, 0), (0,12)->(0,13)),
"TypeError: mismatched arg and param count. Expected 1, got 0. (0,12)->(0,13)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ Environment {
========================

[
Error(MismatchArgs(1, 2), (0,12)->(0,13)),
"TypeError: mismatched arg and param count. Expected 1, got 2. (0,12)->(0,13)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@ expression: "format!(\"{:#?}\\n\\n========================\\n\\n{:#?}\", env, di
---
Environment {
store: [
Spanned(x, (0,4)->(0,5)),
(
"x",
Spanned(Int, (0,4)->(0,5)),
),
],
outer: None,
inner: [],
refs: [
Spanned("x", "(0,4)->(0,5)"),
],
scope_range: "(0,0)->(0,22)",
parent_range: None,
children: [],
}

========================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let a = b;
let add = fn(x,y) {
return x + y;
let a = "foo";
^ [Warning] Code is unreachable
^--^ [Warning] Code is unreachable
};

let ret = add(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ Environment {
========================

[
Warning(UnreachableCode, (3,4)->(3,7)),
"Code is unreachable (3,4)->(3,7)",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
source: src/eval/test.rs
description: "let x = ![];"
expression: "format!(\"{:#?}\\n\\n========================\\n\\n{:#?}\", env, diags)"
---
Environment {
store: [
(
"x",
Spanned(Bool, (0,4)->(0,5)),
),
],
refs: [
Spanned("x", "(0,4)->(0,5)"),
],
scope_range: "(0,0)->(0,12)",
parent_range: None,
children: [],
}

========================

[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
source: src/eval/test.rs
description: "let x = !{};"
expression: "format!(\"{:#?}\\n\\n========================\\n\\n{:#?}\", env, diags)"
---
Environment {
store: [
(
"x",
Spanned(Bool, (0,4)->(0,5)),
),
],
refs: [
Spanned("x", "(0,4)->(0,5)"),
],
scope_range: "(0,0)->(0,12)",
parent_range: None,
children: [],
}

========================

[]
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ Environment {
========================

[
Error(ExpectedTokenNotFound("}"), (0,20)->(0,26)),
"SyntaxError: Expected '}' not found. (0,20)->(0,26)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ Environment {
========================

[
Error(UnknownIdentifier("a"), (0,9)->(0,10)),
Error(UnknownIdentifier("b"), (0,24)->(0,25)),
"NameError: 'a' is not defined. (0,9)->(0,10)",
"NameError: 'b' is not defined. (0,24)->(0,25)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ Environment {
========================

[
Error(UnexpectedToken("@"), (0,12)->(0,13)),
"SyntaxError: Unexpected '@'. (0,12)->(0,13)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ Environment {
========================

[
Warning(UnusedExpression, (0,0)->(0,2)),
Error(UnexpectedToken("@"), (0,12)->(0,13)),
"Expression value is unused (0,0)->(0,2)",
"SyntaxError: Unexpected '@'. (0,12)->(0,13)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Environment {
========================

[
Error(UnknownIdentifier("a"), (0,12)->(0,13)),
Error(UnknownIdentifier("b"), (0,17)->(0,18)),
Error(UnknownIdentifier("c"), (0,28)->(0,29)),
"NameError: 'a' is not defined. (0,12)->(0,13)",
"NameError: 'b' is not defined. (0,17)->(0,18)",
"NameError: 'c' is not defined. (0,28)->(0,29)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ Environment {
========================

[
Error(UnknownIdentifier("b"), (4,12)->(4,13)),
Error(UnknownIdentifier("b"), (6,8)->(6,9)),
"NameError: 'b' is not defined. (4,12)->(4,13)",
"NameError: 'b' is not defined. (6,8)->(6,9)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ Environment {
========================

[
Error(ExpectedTokenNotFound(";"), (0,10)->(0,11)),
"SyntaxError: Expected ';' not found. (0,10)->(0,11)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ Environment {
========================

[
Error(UnexpectedToken(";"), (0,8)->(0,9)),
"SyntaxError: Unexpected ';'. (0,8)->(0,9)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ Environment {
========================

[
Warning(UnusedExpression, (0,7)->(0,8)),
"Expression value is unused (0,7)->(0,8)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ Environment {
========================

[
Warning(UnusedExpression, (0,0)->(0,4)),
"Expression value is unused (0,0)->(0,4)",
]
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ Environment {
========================

[
Warning(UnusedExpression, (0,0)->(0,1)),
Error(UnknownIdentifier("a"), (0,0)->(0,1)),
"Expression value is unused (0,0)->(0,1)",
"NameError: 'a' is not defined. (0,0)->(0,1)",
]
Loading

0 comments on commit 9bddfc0

Please sign in to comment.