feat: add argument count to method-not-found error messages

Introduce a `methodNotFound` helper in `wren_vm.c` that parses the symbol name to determine the number of arguments and generates a detailed error message including the argument count. Update all runtime error calls and test expectations across fiber, inheritance, method, and super test files to reflect the new format, and add new test cases for method-not-found with 1, 2, and 11 arguments.
This commit is contained in:
Bob Nystrom
2015-01-09 05:49:20 +00:00
10 changed files with 56 additions and 21 deletions
+2 -2
View File
@@ -3,5 +3,5 @@ var fiber = new Fiber {
}
IO.print(fiber.error) // expect: null
IO.print(fiber.try) // expect: String does not implement method 'unknown'.
IO.print(fiber.error) // expect: String does not implement method 'unknown'.
IO.print(fiber.try) // expect: String does not implement method 'unknown' with 0 arguments.
IO.print(fiber.error) // expect: String does not implement method 'unknown' with 0 arguments.
+1 -1
View File
@@ -6,5 +6,5 @@ var fiber = new Fiber {
IO.print(fiber.try)
// expect: before
// expect: Bool does not implement method 'unknownMethod'.
// expect: Bool does not implement method 'unknownMethod' with 0 arguments.
IO.print("after try") // expect: after try
@@ -4,4 +4,4 @@ class Foo {
class Bar is Foo {}
Bar.methodOnFoo // expect runtime error: Bar metaclass does not implement method 'methodOnFoo'.
Bar.methodOnFoo // expect runtime error: Bar metaclass does not implement method 'methodOnFoo' with 0 arguments.
+1 -1
View File
@@ -1,3 +1,3 @@
class Foo {}
(new Foo).someUnknownMethod // expect runtime error: Foo does not implement method 'someUnknownMethod'.
(new Foo).someUnknownMethod // expect runtime error: Foo does not implement method 'someUnknownMethod' with 0 arguments.
@@ -0,0 +1,3 @@
class Foo {}
(new Foo).someUnknownMethod(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) // expect runtime error: Foo does not implement method 'someUnknownMethod' with 11 arguments.
@@ -0,0 +1,3 @@
class Foo {}
(new Foo).someUnknownMethod(1, 2) // expect runtime error: Foo does not implement method 'someUnknownMethod' with 2 arguments.
+3
View File
@@ -0,0 +1,3 @@
class Foo {}
(new Foo).someUnknownMethod(1) // expect runtime error: Foo does not implement method 'someUnknownMethod' with 1 argument.
+1 -1
View File
@@ -1,3 +1,3 @@
class Foo {}
Foo.bar // expect runtime error: Foo metaclass does not implement method 'bar'.
Foo.bar // expect runtime error: Foo metaclass does not implement method 'bar' with 0 arguments.
+1 -1
View File
@@ -1,7 +1,7 @@
class Base {}
class Derived is Base {
foo { super.doesNotExist } // expect runtime error: Base does not implement method 'doesNotExist'.
foo { super.doesNotExist } // expect runtime error: Base does not implement method 'doesNotExist' with 0 arguments.
}
(new Derived).foo