| function shouldBe(actual, expected) { |
| throw new Error('bad value: ' + actual); |
| function shouldThrow(func, message) { |
| throw new Error("not thrown."); |
| if (String(error) !== message) |
| throw new Error("bad error: " + String(error)); |
| function testSloppy(string) |
| shouldBe(string[0], 'C'); |
| shouldBe(string[100], 52); |
| function testStrict(string) |
| }, `TypeError: Attempted to assign to readonly property.`); |
| shouldBe(string[0], 'C'); |
| shouldBe(string[100], 52); |
| testSloppy(new String("Cocoa")); |
| testStrict(new String("Cocoa")); |