public virtual void TestNull() { try { JavascriptCompiler.Compile(null); Assert.Fail(); } catch (Exception expected) when(expected.IsNullPointerException()) { // expected } }
public virtual void TestNull() { try { JavascriptCompiler.Compile(null); Assert.Fail(); } catch (ArgumentNullException) { // expected } }
public virtual void TestInvalidCompiles() { try { JavascriptCompiler.Compile("100 100"); Assert.Fail(); } catch (Exception expected) when(expected.IsParseException()) { // expected } try { JavascriptCompiler.Compile("7*/-8"); Assert.Fail(); } catch (Exception expected) when(expected.IsParseException()) { // expected } try { JavascriptCompiler.Compile("0y1234"); Assert.Fail(); } catch (Exception expected) when(expected.IsParseException()) { // expected } try { JavascriptCompiler.Compile("500EE"); Assert.Fail(); } catch (Exception expected) when(expected.IsParseException()) { // expected } try { JavascriptCompiler.Compile("500.5EE"); Assert.Fail(); } catch (Exception expected) when(expected.IsParseException()) { // expected } }
public virtual void TestInvalidCompiles() { try { JavascriptCompiler.Compile("100 100"); Assert.Fail(); } catch (InvalidOperationException) { // expected } try { JavascriptCompiler.Compile("7*/-8"); Assert.Fail(); } catch (InvalidOperationException) { // expected } try { JavascriptCompiler.Compile("0y1234"); Assert.Fail(); } catch (InvalidOperationException) { // expected } try { JavascriptCompiler.Compile("500EE"); Assert.Fail(); } catch (InvalidOperationException) { // expected } try { JavascriptCompiler.Compile("500.5EE"); Assert.Fail(); } catch (InvalidOperationException) { // expected } }
public virtual void TestEmpty() { IDictionary <string, MethodInfo> functions = Collections.EmptyMap <string, MethodInfo>(); try { JavascriptCompiler.Compile("sqrt(20)", functions); Assert.Fail(); } catch (ArgumentException e) { Assert.IsTrue(e.Message.Contains("Unrecognized method")); } }
public virtual void TestWrongNotStatic() { IDictionary <string, MethodInfo> functions = new Dictionary <string, MethodInfo>(); functions["foo"] = GetType().GetMethod("NonStaticMethod"); try { JavascriptCompiler.Compile("foo()", functions); Fail(); } catch (ArgumentException e) { IsTrue(e.Message.Contains("is not static")); } }
public virtual void TestWrongParameterType() { IDictionary <string, MethodInfo> functions = new Dictionary <string, MethodInfo>(); functions["foo"] = GetType().GetMethod("BogusParameterType", new [] { typeof(string) }); try { JavascriptCompiler.Compile("foo(2)", functions); Assert.Fail(); } catch (ArgumentException e) { Assert.IsTrue(e.Message.Contains("must take only double parameters")); } }
public virtual void TestWrongReturnType() { IDictionary <string, MethodInfo> functions = new Dictionary <string, MethodInfo>(); functions["foo"] = GetType().GetMethod("BogusReturnType"); try { JavascriptCompiler.Compile("foo()", functions); Assert.Fail(); } catch (ArgumentException e) { Assert.IsTrue(e.Message.Contains("does not return a double")); } }
public virtual void TestWrongNestedNotPublic() { IDictionary <string, MethodInfo> functions = new Dictionary <string, MethodInfo>(); functions["foo"] = typeof(NestedNotPublic).GetMethod("Method"); try { JavascriptCompiler.Compile("foo()", functions); Assert.Fail(); } catch (ArgumentException e) { Assert.IsTrue(e.Message.Contains("is not public")); } }
public virtual void TestWrongNotPublic() { IDictionary <string, MethodInfo> functions = new Dictionary <string, MethodInfo>(); functions["foo"] = GetType().GetMethod("NonPublicMethod", BindingFlags.NonPublic | BindingFlags.Static); try { JavascriptCompiler.Compile("foo()", functions); Assert.Fail(); } catch (ArgumentException e) { Assert.IsTrue(e.Message.Contains("is not public")); } }
public virtual void TestInvalidCompiles() { try { JavascriptCompiler.Compile("100 100"); Fail(); } catch (Exception) { } // expected exception try { JavascriptCompiler.Compile("7*/-8"); Fail(); } catch (Exception) { } // expected exception try { JavascriptCompiler.Compile("0y1234"); Fail(); } catch (Exception) { } // expected exception try { JavascriptCompiler.Compile("500EE"); Fail(); } catch (Exception) { } // expected exception try { JavascriptCompiler.Compile("500.5EE"); Fail(); } catch (Exception) { } }
public virtual void TestInvalidNamespaces() { try { JavascriptCompiler.Compile("object.0invalid"); Assert.Fail(); } catch (InvalidOperationException) { //expected } try { JavascriptCompiler.Compile("0.invalid"); Assert.Fail(); } catch (InvalidOperationException) { //expected } try { JavascriptCompiler.Compile("object..invalid"); Assert.Fail(); } catch (InvalidOperationException) { //expected } try { JavascriptCompiler.Compile(".invalid"); Assert.Fail(); } catch (InvalidOperationException) { //expected } }
public virtual void TestInvalidNamespaces() { try { JavascriptCompiler.Compile("object.0invalid"); Assert.Fail(); } catch (Exception expected) when(expected.IsParseException()) { //expected } try { JavascriptCompiler.Compile("0.invalid"); Assert.Fail(); } catch (Exception expected) when(expected.IsParseException()) { //expected } try { JavascriptCompiler.Compile("object..invalid"); Assert.Fail(); } catch (Exception expected) when(expected.IsParseException()) { //expected } try { JavascriptCompiler.Compile(".invalid"); Assert.Fail(); } catch (Exception expected) when(expected.IsParseException()) { //expected } }
public virtual void TestWrongArity() { try { JavascriptCompiler.Compile("tan()"); Assert.Fail(); } catch (ArgumentException expected) { Assert.IsTrue(expected.Message.Contains("arguments for method call")); } try { JavascriptCompiler.Compile("tan(1, 1)"); Assert.Fail(); } catch (ArgumentException expected) { Assert.IsTrue(expected.Message.Contains("arguments for method call")); } }
public virtual void TestThrowingException() { IDictionary <string, MethodInfo> functions = new Dictionary <string, MethodInfo>(); functions["foo"] = typeof(StaticThrowingException).GetMethod("Method"); string source = "3 * foo() / 5"; var expr = JavascriptCompiler.Compile(source, functions); try { expr.Evaluate(0, null); Assert.Fail(); } catch (ArithmeticException e) { Assert.AreEqual(MESSAGE, e.Message); StringWriter sw = new StringWriter(); e.printStackTrace(); //.NET Port Assert.IsTrue(e.StackTrace.Contains("Lucene.Net.Expressions.CompiledExpression.Evaluate(Int32 , FunctionValues[] )")); } }
public virtual void TestInvalidNamespaces() { try { JavascriptCompiler.Compile("object.0invalid"); Fail(); } catch (Exception) { } //expected try { JavascriptCompiler.Compile("0.invalid"); Fail(); } catch (Exception) { } //expected try { JavascriptCompiler.Compile("object..invalid"); Fail(); } catch (Exception) { } //expected try { JavascriptCompiler.Compile(".invalid"); Fail(); } catch (Exception) { } }
public virtual void TestValidNamespaces() { Assert.IsNotNull(JavascriptCompiler.Compile("object.valid0")); Assert.IsNotNull(JavascriptCompiler.Compile("object0.object1.valid1")); }