From e7637b3b3c8b3c8b10880a05ab83eb142b994cb5 Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Fri, 23 Aug 2019 08:18:04 -0700 Subject: [PATCH] Test method arity in standard library --- modern/src/maki-interpreter/objects.test.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/modern/src/maki-interpreter/objects.test.js b/modern/src/maki-interpreter/objects.test.js index 9b21c4c2..ae01f65d 100644 --- a/modern/src/maki-interpreter/objects.test.js +++ b/modern/src/maki-interpreter/objects.test.js @@ -24,6 +24,20 @@ for (const [key, Klass] of Object.entries(runtime)) { } expect(Parent.prototype.getclassname()).toBe(obj.parent); }); + describe("methods have the correct arity", () => { + obj.functions.forEach(func => { + const methodName = func.name.toLowerCase(); + // Once all methods are implemented this check can be removed. + // For now we have a separate test which checks that we haven't + // regressed on the methods we've implemented. + if (Klass.prototype.hasOwnProperty(methodName)) { + const actual = Klass.prototype[func.name.toLowerCase()].length; + test(`${obj.name}.${func.name} has an arity of ${actual}`, () => { + expect(func.parameters.length).toBe(actual); + }); + } + }); + }); }); }