feat: add validateNum/validateInt helpers and runtime type checks for list methods

Replace the old validateIndex function with validateNum and validateInt helpers that produce descriptive runtime error messages. Add new test files covering invalid index types, out-of-bounds indices, and iterator validation for list insert, iterate, and iteratorValue methods. Rename existing number operator error tests to use consistent "must be a number" phrasing.
This commit is contained in:
Bob Nystrom
2014-01-02 15:32:00 +00:00
parent 003d4f77f4
commit 6fb8804c9e
25 changed files with 133 additions and 65 deletions
+1
View File
@@ -0,0 +1 @@
1 / false // expect runtime error: Right operand must be a number.
@@ -1 +0,0 @@
1 / false // expect runtime error: TypeError: Right operand must be Num.
+1
View File
@@ -0,0 +1 @@
1 - false // expect runtime error: Right operand must be a number.
@@ -1 +0,0 @@
1 - false // expect runtime error: TypeError: Right operand must be Num.
+1
View File
@@ -0,0 +1 @@
1 % false // expect runtime error: Right operand must be a number.
-1
View File
@@ -1 +0,0 @@
1 % false // expect runtime error: TypeError: Right operand must be Num.
@@ -0,0 +1 @@
1 * false // expect runtime error: Right operand must be a number.
@@ -1 +0,0 @@
1 * false // expect runtime error: TypeError: Right operand must be Num.
+3
View File
@@ -0,0 +1,3 @@
1 + false // expect runtime error: Right operand must be a number.
// TODO: What about a string on the RHS?
@@ -1,3 +0,0 @@
1 + false // expect runtime error: TypeError: Right operand must be Num.
// TODO: What about a string on the RHS?