We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduced test case:
const factoryContract = new Contract<Factory>(); @Contracted(factoryContract) class Factory { child(value: string) { return new Child(value); } @override toString() { throw new TypeError('MUST OVERRIDE'); } } const childContract = new Contract<Child>({ [extend]: factoryContract, [invariant](self) { return self.value.length === 1; } }); @Contracted(childContract) class Child extends Factory { #value: string; constructor(value: string) { super(); this.#value = value; } get value() { return this.#value; } @override override toString() { return `'${this.#value}'`; } } // PASS test('Construct Child', () => { const f = new Factory(), c = f.child('a'); expect(c).toBeInstanceOf(Child); expect(c.value).toBe('a'); }); // FAIL test('Char[toString]()', () => { const f = new Factory(); expect(f.child('a').toString()).toBe('\'a\''); expect(() => { f.child('abc'); }).toThrow(AssertionError); });
Calling toString in the second test causes the invariant to fail:
TypeError: Cannot read properties of undefined (reading 'length')
[invariant](self) { return self.value.length === 1; }
What's strange here is that the getter value seems to work (test 1) but toString seems to not be operating on Child.
value
toString
The text was updated successfully, but these errors were encountered:
Even further reduced test case:
// PASS test('Construct Child', () => { const c = new Child('a'); expect(c).toBeInstanceOf(Child); expect(c.value).toBe('a'); }); // FAIL test('Factory Construct Child', () => { const f = new Factory(), c = f.child('a'); expect(c).toBeInstanceOf(Child); expect(c.value).toBe('a'); });
Sorry, something went wrong.
I wonder if a fix for this would also fix #231
bugfix #236
92fb76b
bugfix #236 (#237)
727afc3
mlhaufe
Successfully merging a pull request may close this issue.
Reduced test case:
Calling toString in the second test causes the invariant to fail:
What's strange here is that the getter
value
seems to work (test 1) buttoString
seems to not be operating on Child.The text was updated successfully, but these errors were encountered: