Ensure we have no extra methods (#861)

This commit is contained in:
Jordan Eldredge 2019-08-18 10:18:29 -07:00 committed by GitHub
parent a45397cf72
commit fe68c78fcc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 17 deletions

View file

@ -27,7 +27,7 @@ for (let [key, Klass] of Object.entries(runtime)) {
});
}
test("Track all missing methods", () => {
describe("Maki classes", () => {
const runtimeMethods = new Set();
const objectMethods = new Set();
for (let [key, Klass] of Object.entries(runtime)) {
@ -40,9 +40,31 @@ test("Track all missing methods", () => {
});
}
const missing = [...objectMethods].filter(x => !runtimeMethods.has(x)).sort();
test("have no extra methods", () => {
// getclassname _should_ be implemented on Object and let each class inherit
// it. However it's far easier to implement it on each class directly, so
// we'll allow that.
function isntGetClassname(method) {
return !/\.getclassname$/.test(method);
}
expect(missing).toMatchInlineSnapshot(`
function isntMakiMethod(method) {
return !objectMethods.has(method);
}
const extra = [...runtimeMethods]
.filter(isntMakiMethod)
.filter(isntGetClassname);
expect(extra).toEqual([]);
});
test("Track all missing methods", () => {
const missing = [...objectMethods]
.filter(x => !runtimeMethods.has(x))
.sort();
expect(missing).toMatchInlineSnapshot(`
Array [
"AnimatedLayer.getautoreplay",
"AnimatedLayer.getcurframe",
@ -696,4 +718,5 @@ Array [
"Wac.show",
]
`);
});
});

View file

@ -22,11 +22,6 @@ class GuiObject extends MakiObject {
return findDescendantByTypeAndId(this, null, id);
}
getobject(id) {
// Not sure this is correct, but it is my understanding this is just an alias
return this.findobject(id);
}
init(newRoot) {
this.parent = newRoot;
newRoot.js_addChild(this);
@ -78,6 +73,11 @@ class GuiObject extends MakiObject {
this.attributes.y = y;
this.attributes.w = w;
this.attributes.h = h;
// TODO: Confirm that GuiObject actually supports these min/max attributes
this.attributes.minimum_w = w;
this.attributes.maximum_w = w;
this.attributes.minimum_h = h;
this.attributes.maximum_h = h;
}
}

View file

@ -15,15 +15,6 @@ class Layout extends Group {
getcontainer() {
return findParentNodeOfType(this, new Set(["container"]));
}
resize(x, y, w, h) {
this.attributes.x = x;
this.attributes.y = y;
this.attributes.minimum_w = w;
this.attributes.maximum_w = w;
this.attributes.minimum_h = h;
this.attributes.maximum_h = h;
}
}
export default Layout;