-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
77 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
class Foo {} | ||
|
||
var foo = Foo(1, 2, 3); | ||
print foo; // expect: Foo instance | ||
var foo = Foo(1, 2, 3); // expect runtime error: Expected 0 arguments but got 3. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
class Foo { | ||
init(a, b) { | ||
print "init"; // expect: init | ||
this.a = a; | ||
this.b = b; | ||
} | ||
} | ||
|
||
var foo = Foo(1, 2, 3, 4); | ||
print foo.a; // expect: 1 | ||
print foo.b; // expect: 2 | ||
var foo = Foo(1, 2, 3, 4); // expect runtime error: Expected 2 arguments but got 4. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// [line 3] Error at '123': Expect '{' before block. | ||
// [c line 4] Error at end: Expect '}' after block. | ||
// original was -> [line 3] Error at '123': Expect '{' before block. | ||
// but because we support lambdas the error is slightly different: | ||
// [line 5] Error at '123': Expect '{' before function body. | ||
// ?? [c line 4] Error at end: Expect '}' after block. | ||
fun f() 123; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
fun f(a, b) { | ||
print a; // expect: 1 | ||
print b; // expect: 2 | ||
print a; | ||
print b; | ||
} | ||
|
||
f(1, 2, 3, 4); | ||
f(1, 2, 3, 4); // expect runtime error: Expected 2 arguments but got 4. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
fun f(a, b) {} | ||
|
||
f(1); // expect runtime error: Not enough arguments. | ||
f(1); // expect runtime error: Expected 2 arguments but got 1. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fun foo() {} | ||
print foo; // expect: <fn foo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
class Foo { | ||
method(a, b) { | ||
print a; // expect: 1 | ||
print b; // expect: 2 | ||
print a; | ||
print b; | ||
} | ||
} | ||
|
||
Foo().method(1, 2, 3, 4); | ||
Foo().method(1, 2, 3, 4); // expect runtime error: Expected 2 arguments but got 4. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
true + "s"; // expect runtime error: Operands must be two numbers or two strings. | ||
// No error here, Chapter 7 challenge 2 implemented. | ||
// true + "s"; expect runtime error: Operands must be two numbers or two strings. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
// [line 3] Error: Unexpected character. | ||
// [line 3] Error: Unexpected character. '|' | ||
// [java line 3] Error at 'b': Expect ')' after arguments. | ||
foo(a | b); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
diff --git a/test/function/body_must_be_block.lox b/test/function/body_must_be_block.lox | ||
index 745a8d0..16f0337 100755 | ||
--- a/test/function/body_must_be_block.lox | ||
+++ b/test/function/body_must_be_block.lox | ||
@@ -1,3 +1,5 @@ | ||
-// [line 3] Error at '123': Expect '{' before block. | ||
-// [c line 4] Error at end: Expect '}' after block. | ||
+// original was -> [line 3] Error at '123': Expect '{' before block. | ||
+// but because we support lambdas the error is slightly different: | ||
+// [line 5] Error at '123': Expect '{' before function body. | ||
+// ?? [c line 4] Error at end: Expect '}' after block. | ||
fun f() 123; | ||
diff --git a/test/operator/add_bool_string.lox b/test/operator/add_bool_string.lox | ||
index 04739d5..0c8c87a 100755 | ||
--- a/test/operator/add_bool_string.lox | ||
+++ b/test/operator/add_bool_string.lox | ||
@@ -1 +1,2 @@ | ||
-true + "s"; // expect runtime error: Operands must be two numbers or two strings. | ||
+// No error here, Chapter 7 challenge 2 implemented. | ||
+// true + "s"; expect runtime error: Operands must be two numbers or two strings. | ||
\ No newline at end of file | ||
diff --git a/test/unexpected_character.lox b/test/unexpected_character.lox | ||
index 5e51396..9ca1244 100755 | ||
--- a/test/unexpected_character.lox | ||
+++ b/test/unexpected_character.lox | ||
@@ -1,3 +1,3 @@ | ||
-// [line 3] Error: Unexpected character. | ||
+// [line 3] Error: Unexpected character. '|' | ||
// [java line 3] Error at 'b': Expect ')' after arguments. | ||
foo(a | b); |