lizzie icon indicating copy to clipboard operation
lizzie copied to clipboard

Unit tests to cover error conditions for variables

Open SapphireBrand opened this issue 7 years ago • 1 comments

Here are two unit tests that I added to TypeScript Lizzie to cover validateThatSymbolIsUndefined in the Binder. This is called from the Var function in Functions.cs, so I added this to my Functions test.

    it('CannotDefineNonSymbol', () => {
        var lambda = LambdaCompiler.compileNoContext(`var(3, 17)`);

        var success = true;
        try {
            lambda();
            success = false;
        } catch (e) {
            expect(e.error).toMatch(/A valid symbol must be specified, but the non-string value '3' was given./i);
        }
        expect(success).toBe(true);
    });

    it('CannotRedefineSymbol', () => {
        var lambda = LambdaCompiler.compileNoContext(`var(@x, 17) var(@x, 17)`);

        var success = true;
        try {
            lambda();
            success = false;
        } catch (e) {
            expect(e.error).toMatch(/The symbol 'x' has already been declared in the scope of where you are trying to declare it using the 'var' keyword./i);
        }
        expect(success).toBe(true);
    });

SapphireBrand avatar Jan 20 '19 18:01 SapphireBrand

Thank you, I'll create something similar in Lizzie later. I'll keep this one open until I do.

polterguy avatar Jan 20 '19 19:01 polterguy