From 77c0845f61d42d27334951b213ac48fabc980582 Mon Sep 17 00:00:00 2001 From: Adnan Ioricce Date: Sun, 6 Oct 2024 13:09:47 +0000 Subject: [PATCH] [Chapter13&Inheritance] - Adding tests;Bugs found - Refactors will be necessary, the interpreter is not working as expected - Try to execute the tests to check the errors - It seems some funcionality with the scanner or resolver is not working - Debugging is necessary. --- tests/class_tests.lox | 35 +++++++++++++++++++++++++++++++++++ tests/vars.lox | 7 +++++++ 2 files changed, 42 insertions(+) create mode 100644 tests/class_tests.lox create mode 100644 tests/vars.lox diff --git a/tests/class_tests.lox b/tests/class_tests.lox new file mode 100644 index 0000000..e7ae390 --- /dev/null +++ b/tests/class_tests.lox @@ -0,0 +1,35 @@ +class A { + method() { + print "A method"; + } +} + +class B < A { + method() { + print "B method"; + } + + test() { + super.method(); + } +} + +class C < B {} + +C().test(); + +class Doughnut { + cook() { + print "Fry until golden brown."; + } +} + +class BostonCream < Doughnut { + cook() { + super.cook(); + print "Pipe full of custard and coat with chocolate."; + } +} + +BostonCream().cook(); + diff --git a/tests/vars.lox b/tests/vars.lox new file mode 100644 index 0000000..56e580c --- /dev/null +++ b/tests/vars.lox @@ -0,0 +1,7 @@ +var a = 0; +a + 1; +print a + 1; +a = 2; +print a + 1; +var b = 3; +print a + b