public void ControlTokensDisabled(string code) { MetricVisitor visitor = new MetricVisitor(); IScriptParser enabledparser = new ScriptParser(); IScriptParser disabledparser = new ScriptParser { ControlTokensEnabled = false }; IScript enabledscript = enabledparser.Parse(code); visitor.Visit(enabledscript); Assert.Greater(visitor.ControlTokens + visitor.FlowTokens, 0); IScript disabledscript = disabledparser.Parse(code); visitor.Visit(disabledscript); Assert.AreEqual(0, visitor.ControlTokens + visitor.FlowTokens); }
public void TypeCastsDisabled() { IScriptParser parser = new ScriptParser { TypeCastsEnabled = false }; IScript script = parser.Parse("$number=int(\"7\")"); MetricVisitor visitor = new MetricVisitor(); visitor.Visit(script); Assert.AreEqual(0, visitor.TypeCasts); }
public void TypeInstanceProvidersDisabled() { IScriptParser parser = new ScriptParser { TypeInstanceProvidersEnabled = false }; IScript script = parser.Parse("$collection=new list() $collection.count"); MetricVisitor visitor = new MetricVisitor(); visitor.Visit(script); Assert.AreEqual(0, visitor.NewInstances); }
public void ImportsDisabled() { ScriptParser parser = new ScriptParser { ImportsEnabled = false, }; parser.MethodResolver = new ResourceScriptMethodProvider(typeof(ImportTests).Assembly, parser); IScript script = parser.Parse( ScriptCode.Create( "$method=import(\"Scripting.Tests.Scripts.External.increasedbyone.ns\")", "return($method.invoke(10))" )); MetricVisitor visitor = new MetricVisitor(); visitor.Visit(script); Assert.AreEqual(0, visitor.Imports); }