示例#1
0
        static void IsString(string s, string v, string msg = null)
        {
            RuntimeObj o = ScriptEngine.Evaluate(s);

            o.Should().BeOfType <StringObj>();
            o.ToString().Should().Be(v, msg ?? s);
        }
示例#2
0
        static void IsString(string s, string v, string msg = null)
        {
            RuntimeObj o = ScriptEngine.Evaluate(s);

            Assert.IsInstanceOf <JSEvalString>(o);
            Assert.That(o.ToString(), Is.EqualTo(v), msg ?? s);
        }
示例#3
0
 static void ExecAsync( string script, Action<RuntimeObj> test, int? expectedFirstChanceError, Expr e, RuntimeObj syncResult, ScriptEngine engine, bool displayResult )
 {
     using( ScriptEngine.Result rAsync = engine.Execute( e ) )
     {
         int nbFirstChanceError = 0;
         int nbStep = 0;
         while( rAsync.CanContinue )
         {
             if( rAsync.Status == ScriptEngineStatus.FirstChanceError ) ++nbFirstChanceError;
             ++nbStep;
             rAsync.Continue();
         }
         test( rAsync.CurrentResult );
         if( expectedFirstChanceError.HasValue ) Assert.That( nbFirstChanceError, Is.EqualTo( expectedFirstChanceError.Value ) );
         if( displayResult ) Console.WriteLine( "Script '{0}' => {1} evaluated in {2} steps ({3} first chance errors).", script, syncResult.ToString(), nbStep, nbFirstChanceError );
     }
 }
示例#4
0
 static void ExecAsync(string script, Action <RuntimeObj> test, int?expectedFirstChanceError, Expr e, RuntimeObj syncResult, ScriptEngine engine, bool displayResult)
 {
     using (ScriptEngine.Result rAsync = engine.Execute(e))
     {
         int nbFirstChanceError = 0;
         int nbStep             = 0;
         while (rAsync.CanContinue)
         {
             if (rAsync.Status == ScriptEngineStatus.FirstChanceError)
             {
                 ++nbFirstChanceError;
             }
             ++nbStep;
             rAsync.Continue();
         }
         test(rAsync.CurrentResult);
         if (expectedFirstChanceError.HasValue)
         {
             nbFirstChanceError.Should().Be(expectedFirstChanceError.Value);
         }
         if (displayResult)
         {
             Console.WriteLine("Script '{0}' => {1} evaluated in {2} steps ({3} first chance errors).", script, syncResult.ToString(), nbStep, nbFirstChanceError);
         }
     }
 }