Skip to content

Commit

Permalink
unit test for #321
Browse files Browse the repository at this point in the history
  • Loading branch information
bjouhier committed Jan 28, 2016
1 parent 0203ce5 commit 46316ec
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions test/common/eval-test._js
Original file line number Diff line number Diff line change
Expand Up @@ -938,3 +938,51 @@ asyncTest("async arrow function", 4, function(_) {
}).call(10, _)
start();
});

asyncTest("optimized array built-ins", 22, function(_) {
[5].forEach_(_, function(_, elt) {
strictEqual(this, "that", "forEach_ this");
strictEqual(elt, 5, "forEach_ elt");
}, "that");
[5].map_(_, function(_, elt) {
strictEqual(this, "that", "map_ this");
strictEqual(elt, 5, "map_ elt");
}, "that");
[5].filter_(_, function(_, elt) {
strictEqual(this, "that", "filter_ this");
strictEqual(elt, 5, "filter_ elt");
}, "that");
[5].every_(_, function(_, elt) {
strictEqual(this, "that", "every_ this");
strictEqual(elt, 5, "every_ elt");
}, "that");
[5].some_(_, function(_, elt) {
strictEqual(this, "that", "some_ this");
strictEqual(elt, 5, "some_ elt");
}, "that");
[5].reduce_(_, function(_, r, elt) {
strictEqual(this, undefined, "reduce_ this");
strictEqual(elt, 5, "reduce_ elt");
}, "result");
[5].reduce_(_, function(_, r, elt) {
strictEqual(this, "that", "reduce_ this");
strictEqual(elt, 5, "reduce_ elt");
}, "result", "that");
[5].reduceRight_(_, function(_, r, elt) {
strictEqual(this, undefined, "reduceRight_ this");
strictEqual(elt, 5, "reduceRight_ elt");
}, "result");
[5].reduceRight_(_, function(_, r, elt) {
strictEqual(this, "that", "reduceRight_ this");
strictEqual(elt, 5, "reduceRight_ elt");
}, "result", "that");
[9, 8].sort_(_, function(_, v1, v2) {
strictEqual(v1, 9, "sort_ v1");
strictEqual(v2, 8, "sort_ v2");
});
[9, 8, 7, 6, 5].sort_(_, function(_, v1, v2) {
strictEqual(v1, 7, "sort_ v1");
strictEqual(v2, 6, "sort_ v2");
}, 2, 3);
start();
});

0 comments on commit 46316ec

Please sign in to comment.