summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Array/prototype/sort/bug_596_1.js
blob: 0298cbc442ecf70ed02a2ca90648df487d62fc89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Copyright (c) 2014 Thomas Dahlstrom. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-array.prototype.sort
description: >
    The SortCompare abstract operation calls ToString() for  identical
    elements (step 14/15)
author: Thomas Dahlstrom (tdahlstrom@gmail.com)
---*/

var counter = 0;
var object = {
  toString: function() {
    counter++;
    return "";
  }
};

[object, object].sort();
if (counter < 2) {
  // sort calls ToString() for each element at least once
  throw new Test262Error('#1: [object, object].sort(); counter < 2. Actual: ' + (counter));
}

reportCompare(0, 0);