Skip to content

Commit 1a01166

Browse files
committed
feat: add new inheritance test cases for error handling and method overriding scenarios
1 parent 8fb275a commit 1a01166

File tree

7 files changed

+29
-2
lines changed

7 files changed

+29
-2
lines changed

internal/tester_definition.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,12 @@ var testerDefinition = tester_definition.TesterDefinition{
338338
TestFunc: createTestForRunCommandStage("i4"),
339339
},
340340
{
341-
Slug: "i5",
342-
TestFunc: createTestForRunCommandStage("i5"),
341+
Slug: "i6",
342+
TestFunc: createTestForRunCommandStage("ioverriding"),
343+
},
344+
{
345+
Slug: "i7",
346+
TestFunc: createTestForRunCommandStage("ierrors"),
343347
},
344348
},
345349
}

test_programs/ierrors/4.lox

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
expected_error_type: compile
3+
---
4+
// A class can't inherit from itself.
5+
class Foo < Foo {} // expect compile error

test_programs/ierrors/5.lox

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
expected_error_type: runtime
3+
---
4+
fun A() {}
5+
6+
// A class can only inherit from a class.
7+
class B < A {} // expect runtime error
8+
9+
print A();
10+
print B();

test_programs/ierrors/6.lox

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
expected_error_type: runtime
3+
---
4+
var A = "class";
5+
6+
class B < A {}
7+
8+
print B();

0 commit comments

Comments
 (0)