keith_miller@apple.com | bcc77f2 | 2016-07-15 06:03:25 +0000 | [diff] [blame] | 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 | info: The production x ^= y is the same as x = x ^ y |
| 6 | es5id: 11.13.2_A4.10_T2.2 |
| 7 | description: > |
| 8 | Type(x) is different from Type(y) and both types vary between |
| 9 | Number (primitive or object) and String (primitive and object) |
| 10 | ---*/ |
| 11 | |
| 12 | var x; |
| 13 | |
| 14 | //CHECK#1 |
| 15 | x = "1"; |
| 16 | x ^= 1; |
| 17 | if (x !== 0) { |
| 18 | $ERROR('#1: x = "1"; x ^= 1; x === 0. Actual: ' + (x)); |
| 19 | } |
| 20 | |
| 21 | //CHECK#2 |
| 22 | x = 1; |
| 23 | x ^= "1"; |
| 24 | if (x !== 0) { |
| 25 | $ERROR('#2: x = 1; x ^= "1"; x === 0. Actual: ' + (x)); |
| 26 | } |
| 27 | |
| 28 | //CHECK#3 |
| 29 | x = new String("1"); |
| 30 | x ^= 1; |
| 31 | if (x !== 0) { |
| 32 | $ERROR('#3: x = new String("1"); x ^= 1; x === 0. Actual: ' + (x)); |
| 33 | } |
| 34 | |
| 35 | //CHECK#4 |
| 36 | x = 1; |
| 37 | x ^= new String("1"); |
| 38 | if (x !== 0) { |
| 39 | $ERROR('#4: x = 1; x ^= new String("1"); x === 0. Actual: ' + (x)); |
| 40 | } |
| 41 | |
| 42 | //CHECK#5 |
| 43 | x = "1"; |
| 44 | x ^= new Number(1); |
| 45 | if (x !== 0) { |
| 46 | $ERROR('#5: x = "1"; x ^= new Number(1); x === 0. Actual: ' + (x)); |
| 47 | } |
| 48 | |
| 49 | //CHECK#6 |
| 50 | x = new Number(1); |
| 51 | x ^= "1"; |
| 52 | if (x !== 0) { |
| 53 | $ERROR('#6: x = new Number(1); x ^= "1"; x === 0. Actual: ' + (x)); |
| 54 | } |
| 55 | |
| 56 | //CHECK#7 |
| 57 | x = new String("1"); |
| 58 | x ^= new Number(1); |
| 59 | if (x !== 0) { |
| 60 | $ERROR('#7: x = new String("1"); x ^= new Number(1); x === 0. Actual: ' + (x)); |
| 61 | } |
| 62 | |
| 63 | //CHECK#8 |
| 64 | x = new Number(1); |
| 65 | x ^= new String("1"); |
| 66 | if (x !== 0) { |
| 67 | $ERROR('#8: x = new Number(1); x ^= new String("1"); x === 0. Actual: ' + (x)); |
| 68 | } |
| 69 | |
| 70 | //CHECK#9 |
| 71 | x = "x"; |
| 72 | x ^= 1; |
| 73 | if (x !== 1) { |
| 74 | $ERROR('#9: x = "x"; x ^= 1; x === 1. Actual: ' + (x)); |
| 75 | } |
| 76 | |
| 77 | //CHECK#10 |
| 78 | x = 1; |
| 79 | x ^= "x"; |
| 80 | if (x !== 1) { |
| 81 | $ERROR('#10: x = 1; x ^= "x"; x === 1. Actual: ' + (x)); |
| 82 | } |