Fix failing tests for rhino -require.

This commit is contained in:
John-David Dalton
2013-10-24 09:09:18 -07:00
parent 5929676ea2
commit e2c5e92cd3
2 changed files with 17 additions and 20 deletions

View File

@@ -524,13 +524,13 @@
var bound = _.bind(func, null), var bound = _.bind(func, null),
actual = bound('a'); actual = bound('a');
ok(actual[0] === null || actual[0] === root); ok(actual[0] === null || actual[0] && actual[0].Array);
equal(actual[1], 'a'); equal(actual[1], 'a');
bound = _.bind(func, undefined); bound = _.bind(func, undefined);
actual = bound('b'); actual = bound('b');
ok(actual[0] === undefined || actual[0] === root); ok(actual[0] === undefined || actual[0] && actual[0].Array);
equal(actual[1], 'b'); equal(actual[1], 'b');
}); });
@@ -6008,33 +6008,33 @@
test('should work with custom `_.templateSettings` delimiters', 1, function() { test('should work with custom `_.templateSettings` delimiters', 1, function() {
var settings = _.clone(_.templateSettings); var settings = _.clone(_.templateSettings);
_.templateSettings = { _.assign(_.templateSettings, {
'escape': /\{\{-([\s\S]+?)\}\}/g, 'escape': /\{\{-([\s\S]+?)\}\}/g,
'evaluate': /\{\{([\s\S]+?)\}\}/g, 'evaluate': /\{\{([\s\S]+?)\}\}/g,
'interpolate': /\{\{=([\s\S]+?)\}\}/g 'interpolate': /\{\{=([\s\S]+?)\}\}/g
}; });
var compiled = _.template('<ul>{{ _.each(collection, function(value, index) { }}<li>{{= index }}: {{- value }}</li>{{ }); }}</ul>'), var compiled = _.template('<ul>{{ _.each(collection, function(value, index) { }}<li>{{= index }}: {{- value }}</li>{{ }); }}</ul>'),
expected = '<ul><li>0: a &amp; A</li><li>1: b &amp; B</li></ul>'; expected = '<ul><li>0: a &amp; A</li><li>1: b &amp; B</li></ul>';
equal(compiled({ 'collection': ['a & A', 'b & B'] }), expected); equal(compiled({ 'collection': ['a & A', 'b & B'] }), expected);
_.extend(_.templateSettings, settings); _.assign(_.templateSettings, settings);
}); });
test('should work with `_.templateSettings` delimiters containing special characters', 1, function() { test('should work with `_.templateSettings` delimiters containing special characters', 1, function() {
var settings = _.clone(_.templateSettings); var settings = _.clone(_.templateSettings);
_.templateSettings = { _.assign(_.templateSettings, {
'escape': /<\?-([\s\S]+?)\?>/g, 'escape': /<\?-([\s\S]+?)\?>/g,
'evaluate': /<\?([\s\S]+?)\?>/g, 'evaluate': /<\?([\s\S]+?)\?>/g,
'interpolate': /<\?=([\s\S]+?)\?>/g 'interpolate': /<\?=([\s\S]+?)\?>/g
}; });
var compiled = _.template('<ul><? _.each(collection, function(value, index) { ?><li><?= index ?>: <?- value ?></li><? }); ?></ul>'), var compiled = _.template('<ul><? _.each(collection, function(value, index) { ?><li><?= index ?>: <?- value ?></li><? }); ?></ul>'),
expected = '<ul><li>0: a &amp; A</li><li>1: b &amp; B</li></ul>'; expected = '<ul><li>0: a &amp; A</li><li>1: b &amp; B</li></ul>';
equal(compiled({ 'collection': ['a & A', 'b & B'] }), expected); equal(compiled({ 'collection': ['a & A', 'b & B'] }), expected);
_.extend(_.templateSettings, settings); _.assign(_.templateSettings, settings);
}); });
test('supports recursive calls', 1, function() { test('supports recursive calls', 1, function() {

View File

@@ -173,26 +173,23 @@
console.log(' Finished in ' + details.runtime + ' milliseconds.'); console.log(' Finished in ' + details.runtime + ' milliseconds.');
console.log(hr); console.log(hr);
var fails = details.failed,
error = fails + ' of ' + details.total + ' tests failed.';
// exit out of Node.js or PhantomJS // exit out of Node.js or PhantomJS
try { try {
var process = context.process || context.phantom; var process = context.process || context.phantom;
if (fails) { if (details.failed) {
console.error('Error: ' + error);
process.exit(1); process.exit(1);
} else { } else {
process.exit(0); process.exit(0);
} }
} catch(e) { } catch(e) { }
if (fails) {
throw new Error(error); // exit out of Narwhal, Rhino, or RingoJS
}
}
// exit out of Narhwal, Rhino, or RingoJS
try { try {
quit(); if (details.failed) {
java.lang.System.exit(1);
} else {
quit();
}
} catch(e) { } } catch(e) { }
}; };
}()); }());