mirror of
https://github.com/MorizzG/rlox.git
synced 2025-12-06 12:22:42 +00:00
added tests
This commit is contained in:
parent
1cca1494a4
commit
660464638f
255 changed files with 7220 additions and 3 deletions
22
interpreter/tests/lox/method/arity.lox
Normal file
22
interpreter/tests/lox/method/arity.lox
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
class Foo {
|
||||
method0() { return "no args"; }
|
||||
method1(a) { return a; }
|
||||
method2(a, b) { return a + b; }
|
||||
method3(a, b, c) { return a + b + c; }
|
||||
method4(a, b, c, d) { return a + b + c + d; }
|
||||
method5(a, b, c, d, e) { return a + b + c + d + e; }
|
||||
method6(a, b, c, d, e, f) { return a + b + c + d + e + f; }
|
||||
method7(a, b, c, d, e, f, g) { return a + b + c + d + e + f + g; }
|
||||
method8(a, b, c, d, e, f, g, h) { return a + b + c + d + e + f + g + h; }
|
||||
}
|
||||
|
||||
var foo = Foo();
|
||||
print foo.method0(); // expect: no args
|
||||
print foo.method1(1); // expect: 1
|
||||
print foo.method2(1, 2); // expect: 3
|
||||
print foo.method3(1, 2, 3); // expect: 6
|
||||
print foo.method4(1, 2, 3, 4); // expect: 10
|
||||
print foo.method5(1, 2, 3, 4, 5); // expect: 15
|
||||
print foo.method6(1, 2, 3, 4, 5, 6); // expect: 21
|
||||
print foo.method7(1, 2, 3, 4, 5, 6, 7); // expect: 28
|
||||
print foo.method8(1, 2, 3, 4, 5, 6, 7, 8); // expect: 36
|
||||
Loading…
Add table
Add a link
Reference in a new issue