summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Array/prototype/toString/S15.4.4.2_A1_T2.js
blob: 8a6b4f74ad44959cfd0c164692c145f2e69ab80c (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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright 2009 the Sputnik authors.  All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-array.prototype.tostring
info: |
    The result of calling this function is the same as if
    the built-in join method were invoked for this object with no argument
es5id: 15.4.4.2_A1_T2
description: >
    The elements of the array are converted to strings, and these
    strings are  then concatenated, separated by occurrences of the
    separator. If no separator is provided,  a single comma is used as
    the separator
---*/

var x = new Array(0, 1, 2, 3);
if (x.toString() !== x.join()) {
  throw new Test262Error('#1.1: x = new Array(0,1,2,3); x.toString() === x.join(). Actual: ' + (x.toString()));
} else {
  if (x.toString() !== "0,1,2,3") {
    throw new Test262Error('#1.2: x = new Array(0,1,2,3); x.toString() === "0,1,2,3". Actual: ' + (x.toString()));
  }
}

x = [];
x[0] = 0;
x[3] = 3;
if (x.toString() !== x.join()) {
  throw new Test262Error('#2.1: x = []; x[0] = 0; x[3] = 3; x.toString() === x.join(). Actual: ' + (x.toString()));
} else {
  if (x.toString() !== "0,,,3") {
    throw new Test262Error('#2.2: x = []; x[0] = 0; x[3] = 3; x.toString() === "0,,,3". Actual: ' + (x.toString()));
  }
}

x = Array(undefined, 1, null, 3);
if (x.toString() !== x.join()) {
  throw new Test262Error('#3.1: x = Array(undefined,1,null,3); x.toString() === x.join(). Actual: ' + (x.toString()));
} else {
  if (x.toString() !== ",1,,3") {
    throw new Test262Error('#3.2: x = Array(undefined,1,null,3); x.toString() === ",1,,3". Actual: ' + (x.toString()));
  }
}

x = [];
x[0] = 0;
if (x.toString() !== x.join()) {
  throw new Test262Error('#4.1: x = []; x[0] = 0; x.toString() === x.join(). Actual: ' + (x.toString()));
} else {
  if (x.toString() !== "0") {
    throw new Test262Error('#4.2: x = []; x[0] = 0; x.toString() === "0". Actual: ' + (x.toString()));
  }
}

reportCompare(0, 0);