Exemple #1
0
 public static ErrorInstance MakeError(Assert self, object actual, object expected, object message, object operatr) {
     bool generated = false;
     if (message == null || TypeComparer.Equals(message, Undefined.Value)) {
         message = truncate(JSONObject.Stringify(self.Engine, actual), 128)
                 + ' '
                 + operatr
                 + ' '
                 + truncate(JSONObject.Stringify(self.Engine, expected), 128);
         generated = true;
     }
     ErrorInstance err = self.Engine.Error.Construct(message as string);
     err.SetPropertyValue("message", message, false);
     err.SetPropertyValue("name", "AssertionError", false);
     err.SetPropertyValue("actual", actual, false);
     err.SetPropertyValue("expected", expected, false);
     err.SetPropertyValue("operator", operatr, false);
     err.SetPropertyValue("generatedMessage", generated, false);
     return err;
 }
Exemple #2
0
        public Context()
        {
            Engine = new ScriptEngine();
            Engine.Global = new ContextGlobalObject(this);

            Modules.Add("assert", Assert = new Libraries.Assert(this));
            Modules.Add("util", Util = new Libraries.Util(this));
            Modules.Add("path", Path = new Libraries.Path(this));
            Modules.Add("events", Events = new Libraries.Events(this));
            Modules.Add("timers", Timers = new Libraries.Timers(this));
            Modules.Add("buffer", Buffer = new Libraries.Buffer(this));
            Modules.Add("string_decoder", StringDecoder = new Libraries.StringDecoder(this));
            Modules.Add("querystring", QueryString = new Libraries.QueryString(this));
            // Modules.Add("stream", Stream = new Libraries.Stream(this));
            Modules.Add("fs", Fs = new Libraries.Fs(this));
            Modules.Add("console", Console = new Libraries.Console(this));

            Process = new Libraries.Process(this);
            RegisterGlobals();
        }