|
1 // Copyright 2009 the Sputnik authors. All rights reserved. |
|
2 // This code is governed by the BSD license found in the LICENSE file. |
|
3 |
|
4 /** |
|
5 * The production x += y is the same as x = x + y |
|
6 * |
|
7 * @path ch11/11.13/11.13.2/S11.13.2_A4.4_T1.4.js |
|
8 * @description Type(x) and Type(y) vary between primitive string and String object |
|
9 */ |
|
10 |
|
11 //CHECK#1 |
|
12 x = "1"; |
|
13 x += "1"; |
|
14 if (x !== "11") { |
|
15 $ERROR('#1: x = "1"; x += "1"; x === "11". Actual: ' + (x)); |
|
16 } |
|
17 |
|
18 //CHECK#2 |
|
19 x = new String("1"); |
|
20 x += "1"; |
|
21 if (x !== "11") { |
|
22 $ERROR('#2: x = new String("1"); x += "1"; x === "11". Actual: ' + (x)); |
|
23 } |
|
24 |
|
25 //CHECK#3 |
|
26 x = "1"; |
|
27 x += new String("1"); |
|
28 if (x !== "11") { |
|
29 $ERROR('#3: x = "1"; x += new String("1"); x === "11". Actual: ' + (x)); |
|
30 } |
|
31 |
|
32 //CHECK#4 |
|
33 x = new String("1"); |
|
34 x += new String("1"); |
|
35 if (x !== "11") { |
|
36 $ERROR('#4: x = new String("1"); x += new String("1"); x === "11". Actual: ' + (x)); |
|
37 } |
|
38 |
|
39 //CHECK#5 |
|
40 if ("x" + "1" !=="x1") { |
|
41 $ERROR('#5: x = "x"; x += "1"; x === "x1". Actual: ' + (x)); |
|
42 } |
|
43 |
|
44 //CHECK#6 |
|
45 x = "1"; |
|
46 x += "x"; |
|
47 if (x !== "1x") { |
|
48 $ERROR('#6: x = "1"; x += "x"; x === "1x". Actual: ' + (x)); |
|
49 } |
|
50 |