public void Parse_Five_5() { var str = new Constant("5"); var parsed = new Apply(Funcs.Parse, str).Specialize(Typs.Double); var o = parsed.Evaluate(null); Assert.Equal(5d, o); }
public void TestAll_NoMatch_No() { var tagsAx = new Dictionary <string, string> { { "a", "b" }, }; var expr = new Apply(MustMatchJson(), new Constant(tagsAx)).Optimize(); var result = expr.Evaluate(new Context()); Assert.Equal("no", result); }
public void EitherFunc_SpecializeToString_Const() { var a = new Constant("a"); var mconst = new Apply(new Apply(Funcs.EitherFunc, Funcs.Id), Funcs.Const); var specialized = new Apply(mconst, a).Specialize(Typs.String); Assert.Equal("((($firstArg $id) $firstArg) \"a\")", specialized.ToString()); Assert.Equal("string; $b -> string", string.Join("; ", new Apply(mconst, a).Types)); Assert.Equal("\"a\"", specialized.Evaluate(null).Pretty()); Assert.Equal("\"a\"", new Apply(new Apply(mconst, a), new Constant("42")).Specialize(Typs.String) .Evaluate(null) .Pretty()); }