mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-02 16:17:50 +00:00
lodash: Sync with Underscore.js commits. [jddalton]
Former-commit-id: 0a92b5c9dcd0ff5c4c712e083fa60556ebb1d96a
This commit is contained in:
@@ -260,6 +260,9 @@ $(document).ready(function() {
|
||||
var numbers = [10, 20, 30, 40, 50], num = 35;
|
||||
var index = _.sortedIndex(numbers, num);
|
||||
equal(index, 3, '35 should be inserted at index 3');
|
||||
|
||||
var index2 = _.sortedIndex(numbers, 30);
|
||||
equal(index2, 2, '30 should be inserted at index 2');
|
||||
});
|
||||
|
||||
test('collections: shuffle', function() {
|
||||
|
||||
@@ -192,4 +192,32 @@ $(document).ready(function() {
|
||||
ok(!_.templateSettings.variable);
|
||||
});
|
||||
|
||||
test('#556 - undefined template variables.', function() {
|
||||
var template = _.template('<%=x%>');
|
||||
strictEqual(template({x: null}), '');
|
||||
strictEqual(template({x: undefined}), '');
|
||||
|
||||
var templateEscaped = _.template('<%-x%>');
|
||||
strictEqual(templateEscaped({x: null}), '');
|
||||
strictEqual(templateEscaped({x: undefined}), '');
|
||||
|
||||
var templateWithProperty = _.template('<%=x.foo%>');
|
||||
strictEqual(templateWithProperty({x: {} }), '');
|
||||
strictEqual(templateWithProperty({x: {} }), '');
|
||||
|
||||
var templateWithPropertyEscaped = _.template('<%-x.foo%>');
|
||||
strictEqual(templateWithPropertyEscaped({x: {} }), '');
|
||||
strictEqual(templateWithPropertyEscaped({x: {} }), '');
|
||||
});
|
||||
|
||||
test('interpolate evaluates code only once.', 2, function() {
|
||||
var count = 0;
|
||||
var template = _.template('<%= f() %>');
|
||||
template({f: function(){ ok(!(count++)); }});
|
||||
|
||||
var countEscaped = 0;
|
||||
var templateEscaped = _.template('<%- f() %>');
|
||||
templateEscaped({f: function(){ ok(!(countEscaped++)); }});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user