Sha256: 8b7504795113d81769e5dc65919c37613714d07199db00618105960e7bee57ce

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

// ==========================================================================
// Project:   Spade - CommonJS Runtime
// Copyright: ©2011 Strobe Inc. All rights reserved.
// License:   Licened under MIT license (see __preamble__.js)
// ==========================================================================

var Ct = require('core-test/sync'),
    Spade = require('spade').Spade,
    Sandbox = require('spade').Sandbox;

Ct.module('spade: Sandbox evaluation');

Ct.setup(function(t) {
  t.sandbox = new Sandbox(new Spade());
});

Ct.teardown(function(t) {
  delete t.sandbox;
});

Ct.test('normal', function(t){
  t.equal(t.sandbox._evaluatorInited, undefined);
  t.equal(t.sandbox.evaluate('2 * 2'), 4);
  t.equal(t.sandbox._evaluatorInited, true);
});

Ct.test('already initialized', function(t){
  // Initialize
  t.sandbox.evaluate('');
  // Test
  t.equal(t.sandbox.evaluate('3 * 3'), 9);
});

Ct.test('destroyed', function(t){
  t.sandbox.destroy();
  t.throws(function(){ t.sandbox.evaluate('4 * 4'); }, Error, "Sandbox destroyed");
});

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spade-0.1.1.1 lib/spade/package/spec/javascript/sandbox/evaluate.js