]> git.saurik.com Git - apple/javascriptcore.git/blame - tests/stress/static-getter-delete.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / static-getter-delete.js
CommitLineData
ed1e77d3
A
1function shouldBe(actual, expected) {
2 if (actual !== expected)
3 throw new Error('bad value: ' + actual);
4}
5
6function shouldThrow(func, errorMessage) {
7 var errorThrown = false;
8 var error = null;
9 try {
10 func();
11 } catch (e) {
12 errorThrown = true;
13 error = e;
14 }
15 if (!errorThrown)
16 throw new Error('not thrown');
17 if (String(error) !== errorMessage)
18 throw new Error(`bad error: ${String(error)}`);
19}
20
21// Before static functions (& accessors) are reified.
22shouldThrow(function () {
23 'use strict';
24 RegExp.prototype.multiline = 'ok';
25}, 'TypeError: Attempted to assign to readonly property.');
26
27(function () {
28 'use strict';
29 shouldBe(delete RegExp.prototype.global, true);
30 shouldBe(RegExp.prototype.hasOwnProperty('global'), false);
31 RegExp.prototype.global = 'hello'
32 shouldBe(RegExp.prototype.global, 'hello');
33}());
34
35// After static functions (& accessors) are reified.
36shouldThrow(function () {
37 'use strict';
38 RegExp.prototype.multiline = 'ok';
39}, 'TypeError: Attempted to assign to readonly property.');
40
41(function () {
42 'use strict';
43 shouldBe(delete RegExp.prototype.multiline, true);
44 shouldBe(RegExp.prototype.hasOwnProperty('multiline'), false);
45 RegExp.prototype.multiline = 'hello'
46 shouldBe(RegExp.prototype.multiline, 'hello');
47}());