コード例 #1
0
function DefaultRemote () {
  this.context = Script.createContext();
  for (var i in global) this.context[i] = global[i];
  this.context.module = module;
  this.context.require = function(id, options) {
    // Remove module from cache if reload is requested.
    if (options && options.reload)
      delete require.cache[require.resolve(id)];
    return require(id);
  }
  var self = this;
  this.context._swank = {
    output: function output (arg) {
      self.output(arg);
    },

    inspect: function inspect () {
      Array.prototype.forEach.call(arguments, function (arg) {      
        self.output(util.inspect(arg, false, 10));
        self.output('\n');
      }); 
    }
    
  };
  this.context.inspect = this.context._swank.inspect;
}
コード例 #2
0
ファイル: coffee-remote.js プロジェクト: hanachin/swank-js
// CoffeeScript
function CoffeeRemote (clientInfo, client) {
  this.context = Script.createContext();
  for (var i in global) this.context[i] = global[i];
  this.context.module = module;
  this.context.require = require;
  var self = this;
  this.context._swank = {
    output: function output (arg) {
      self.output(arg);
    }
  };
}
コード例 #3
0
ファイル: swank-handler.js プロジェクト: xiaonaitong/swank-js
function DefaultRemote () {
  this.context = Script.createContext();
  for (var i in global) this.context[i] = global[i];
  this.context.module = module;
  this.context.require = function(id, options) {
    // Remove module from cache if reload is requested.
    if (options && options.reload)
      delete require.cache[require.resolve(id)];
    return require(id);
  }
  var self = this;
  this.context._swank = {
    output: function output (arg) {
      self.output(arg);
    }
  };
}
コード例 #4
0
  [{fn: new Function('')}, 'fn=', {'fn': ''}],
  [{math: Math}, 'math=', {'math': ''}],
  [{e: extendedFunction}, 'e=', {'e': ''}],
  [{d: new Date()}, 'd=', {'d': ''}],
  [{d: Date}, 'd=', {'d': ''}],
  [{f: new Boolean(false), t: new Boolean(true)}, 'f=&t=', {'f': '', 't': ''}],
  [{f: false, t: true}, 'f=false&t=true', {'f': 'false', 't': 'true'}],
  [{n: null}, 'n=', {'n': ''}],
  [{nan: NaN}, 'nan=', {'nan': ''}],
  [{inf: Infinity}, 'inf=', {'inf': ''}]
];
// }}}

var Script = require('vm').Script;
var foreignObject = Script.runInContext('({"foo": ["bar", "baz"]})',
                                        Script.createContext());

var qsNoMungeTestCases = [
  ['', {}],
  ['foo=bar&foo=baz', {'foo': ['bar', 'baz']}],
  ['foo=bar&foo=baz', foreignObject],
  ['blah=burp', {'blah': 'burp'}],
  ['gragh=1&gragh=3&goo=2', {'gragh': ['1', '3'], 'goo': '2'}],
  ['frappucino=muffin&goat%5B%5D=scone&pond=moose',
   {'frappucino': 'muffin', 'goat[]': 'scone', 'pond': 'moose'}],
  ['trololol=yes&lololo=no', {'trololol': 'yes', 'lololo': 'no'}]
];

assert.strictEqual('918854443121279438895193',
                   qs.parse('id=918854443121279438895193').id);
コード例 #5
0
var common = require('../common');
var assert = require('assert');

var Script = require('vm').Script;
var script = new Script('"passed";');

common.debug('run in a new empty context');
var context = script.createContext();
var result = script.runInContext(context); 
assert.equal('passed', result);

common.debug('create a new pre-populated context');
context = script.createContext({'foo': 'bar', 'thing': 'lala'});
assert.equal('bar', context.foo);
assert.equal('lala', context.thing);

common.debug('test updating context');
script = new Script('foo = 3;');
result = script.runInContext(context);
assert.equal(3, context.foo);
assert.equal('lala', context.thing);


// Issue GH-227:
Script.runInNewContext('', null, 'some.js');
コード例 #6
0
ファイル: test-querystring.js プロジェクト: ARenzi/node
  [ {fn:function () {}}, "fn=", {"fn":""}],
  [ {fn:new Function("")}, "fn=", {"fn":""} ],
  [ {math:Math}, "math=", {"math":""} ],
  [ {e:extendedFunction}, "e=", {"e":""} ],
  [ {d:new Date()}, "d=", {"d":""} ],
  [ {d:Date}, "d=", {"d":""} ],
  [ {f:new Boolean(false), t:new Boolean(true)}, "f=&t=", {"f":"", "t":""} ],
  [ {f:false, t:true}, "f=false&t=true", {"f":"false", "t":"true"} ],
  [ {n:null}, "n=", {"n":""} ],
  [ {nan:NaN}, "nan=", {"nan":""} ],
  [ {inf:Infinity}, "inf=", {"inf":""} ]
];
}

var Script = require('vm').Script;
var foreignObject = Script.runInContext('({"foo": ["bar", "baz"]})', Script.createContext());

var qsNoMungeTestCases = [
  ["", {}],
  ["foo=bar&foo=baz", {"foo": ["bar", "baz"]}],
  ["foo=bar&foo=baz", foreignObject],
  ["blah=burp", {"blah": "burp"}],
  ["gragh=1&gragh=3&goo=2", {"gragh": ["1", "3"], "goo": "2"}],
  ["frappucino=muffin&goat%5B%5D=scone&pond=moose",
   {"frappucino": "muffin", "goat[]": "scone", "pond": "moose"}],
  ["trololol=yes&lololo=no", {"trololol": "yes", "lololo": "no"}]
];

assert.strictEqual("918854443121279438895193", qs.parse("id=918854443121279438895193").id);

// test that the canonical qs is parsed properly.