public void InvokeMethod() { SubrDotInvoke subr = new SubrDotInvoke("ToString"); var result = subr.Apply(List.Create(new object[] { 123 }), null); Assert.IsNotNull(result); Assert.AreEqual("123", result); }
public void InvokeMethodWithArguments() { SubrDotInvoke subr = new SubrDotInvoke("Substring"); var result = subr.Apply(List.Create(new object[] { "foobarfoo", 3, 3 }), null); Assert.IsNotNull(result); Assert.AreEqual("bar", result); }
public void GetProperty() { SubrDotInvoke subr = new SubrDotInvoke("Length"); var result = subr.Apply(List.Create(new object[] { "foo" }), null); Assert.IsNotNull(result); Assert.AreEqual(3, result); }
private List CompileList() { if (this.NextTokenIs(TokenType.Separator, ')')) { return(null); } object first = this.CompileTerm(); if (first is Identifier) { var id = (Identifier)first; if (id.Name.Length > 1) { if (id.Name.EndsWith(".")) { first = new SubrDotNew(id.Name.Substring(0, id.Name.Length - 1)); } else if (id.Name.StartsWith(".")) { first = new SubrDotInvoke(id.Name.Substring(1)); } } } object rest; if (this.NextTokenIs(TokenType.Name, ".")) { rest = this.CompileTerm(); this.ParseNextToken(TokenType.Separator, ')'); } else { rest = this.CompileList(); } List list = new List(first, rest); return(list); }