public void SemanticError39() { GlobalSymbolList globals = new GlobalSymbolList(); globals.Add("method", TestHelpers.MakeTestFunction(IrisType.Integer, new IrisType[] { IrisType.Integer })); string input = @"method"; TestHelpers.TestExpressionParserWithError(input, globals, @"(1, 1) Wrong number of arguments for function 'method'. 1 expected. 0 provided."); }
public void SemanticError29() { GlobalSymbolList globals = new GlobalSymbolList(); globals.Add("method", TestHelpers.MakeTestFunction(IrisType.Integer, new IrisType[] { IrisType.Integer.MakeByRefType() })); string input = @"method(false)"; TestHelpers.TestExpressionParserWithError(input, globals, @"(1, 8) Cannot take address of constant, call, or expression."); }
public void SemanticError18() { GlobalSymbolList globals = new GlobalSymbolList(); globals.Add("method", TestHelpers.MakeTestFunction(IrisType.Integer, new IrisType[] { IrisType.Integer })); string input = @"method(false)"; TestHelpers.TestExpressionParserWithError(input, globals, @"(1, 8) Argument type doesn't match parameter 'p0' of function 'method'"); }
public void Expression25() { GlobalSymbolList globals = new GlobalSymbolList(); globals.Add("method", TestHelpers.MakeTestFunction(IrisType.Integer, new IrisType[] { IrisType.Integer.MakeByRefType() })); globals.Add("a", IrisType.Integer); string input = @"method((a))"; string output = TestHelpers.TestExpressionParser(input, globals); string expected = @"ldsflda 0 call _Unknown "; Assert.AreEqual(expected, output); }
public void SimpleWithParams() { GlobalSymbolList globals = new GlobalSymbolList(); globals.Add("global", IrisType.Integer); globals.Add("method", TestHelpers.MakeTestFunction(IrisType.Integer, new IrisType[] { IrisType.Integer, IrisType.Integer, IrisType.Boolean, IrisType.Integer })); string input = @"method(1, -2, false, global)"; string output = TestHelpers.TestExpressionParser(input, globals); string expected = @"ldc.i4.1 ldc.i4.2 neg ldc.i4.0 ldsfld 0 call _Unknown "; Assert.AreEqual(expected, output); }
public void Expression19() { GlobalSymbolList globals = new GlobalSymbolList(); globals.Add("strcmp", TestHelpers.MakeTestFunction(IrisType.Integer, new IrisType[] { IrisType.Integer, IrisType.Integer })); globals.Add("a", IrisType.String); globals.Add("b", IrisType.String); string input = @"a = b"; string output = TestHelpers.TestExpressionParser(input, globals); string expected = @"ldsfld 0 ldsfld 1 call _Unknown ldc.i4.0 ceq "; Assert.AreEqual(expected, output); }