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);
});
Here are two unit tests that I added to TypeScript Lizzie to cover
validateThatSymbolIsUndefinedin the Binder. This is called from the Var function in Functions.cs, so I added this to my Functions test.