| function shouldBe(actual, expected) { |
| throw new Error('bad value: ' + actual); |
| function shouldThrow(func, errorMessage) { |
| throw new Error('not thrown'); |
| if (String(error) !== errorMessage) |
| throw new Error(`bad error: ${String(error)}`); |
| shouldThrow(function () { |
| RegExp.prototype.global = 'Cocoa'; |
| }, 'TypeError: Attempted to assign to readonly property.'); |
| shouldThrow(function () { |
| RegExp.prototype.global = 'Cocoa'; |
| }, 'TypeError: Attempted to assign to readonly property.'); |
| delete RegExp.prototype.global; |
| RegExp.prototype.global = 'Cocoa'; |
| shouldBe(RegExp.prototype.global, 'Cocoa'); |
| shouldBe(/Cappuccino/.global, 'Cocoa'); |