Skip to content
New issue

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

Unit tests to cover error conditions for variables #47

Open
SapphireBrand opened this issue Jan 20, 2019 · 1 comment
Open

Unit tests to cover error conditions for variables #47

SapphireBrand opened this issue Jan 20, 2019 · 1 comment

Comments

@SapphireBrand
Copy link

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);
    });
@polterguy
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants