public void variable_declaration_without_type_equals_null() { // let var x:=nil in x and var target = new LetInExpression { VariableDeclarations = new List<VariableDeclarationBase> { new VariableDeclarationExpression { VariableName = new MemberIdentifierNode {Name = "x"}, VariableTypeName = new TypeReferenceNode(), Value = new NullLiteralExpression() } }, Body = new ListSemiExpression { new VariableAccessExpression {VariableName = "x"} } }; AstHelper helper = Mother.CreateRuntime(); try { target.Compile(helper); } catch (SemanticException e) { var error = e.Errors.First() as CanNotInferTypeError; Assert.IsNotNull(error); Assert.Pass(); } Assert.Fail(); }
public void variable_initialization_with_undefined_function() { // let var x:=Foo() in x and var target = new LetInExpression { VariableDeclarations = new List<VariableDeclarationBase> { new VariableDeclarationExpression { VariableName = new MemberIdentifierNode {Name = "x"}, VariableTypeName = new TypeReferenceNode(), Value = new FunctionInvokeExpression { FunctionName = new IdentifierNode {Name = "Foo"} } } }, Body = new ListSemiExpression { new VariableAccessExpression {VariableName = "x"} } }; AstHelper helper = Mother.CreateRuntime(); try { target.Compile(helper); } catch (SemanticException e) { var error = e.Errors.First() as FunctionNotDefinedError; Assert.IsNotNull(error); } }