|
| 1 | +// Copyright JS Foundation and other contributors, http://js.foundation |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +var func = function (number) { |
| 16 | + "use strict"; |
| 17 | + number.foo = ""; |
| 18 | +}; |
| 19 | + |
| 20 | +var func2 = function (number) { |
| 21 | + "use strict"; |
| 22 | + number.bar = ""; |
| 23 | +}; |
| 24 | + |
| 25 | +try { |
| 26 | + func(-334918463); |
| 27 | + assert(false); |
| 28 | +} catch (e) { |
| 29 | + assert(e instanceof TypeError); |
| 30 | +} |
| 31 | + |
| 32 | +try { |
| 33 | + Object.defineProperty(Number.prototype, "foo", { get : function() { throw ReferenceError("foo"); }, |
| 34 | + set : function(a) { throw ReferenceError("bar"); }, |
| 35 | + }); |
| 36 | + func(-334918463); |
| 37 | + assert(false); |
| 38 | +} catch (e) { |
| 39 | + assert(e instanceof ReferenceError); |
| 40 | + assert(e.message === "bar"); |
| 41 | +} |
| 42 | + |
| 43 | +var setter_called = false; |
| 44 | +Object.defineProperty(Number.prototype, "bar", { get : function() { assert(false) }, |
| 45 | + set : function(a) { setter_called = true; }, |
| 46 | + }); |
| 47 | +func2(-334918463); |
| 48 | +assert(setter_called === true); |
0 commit comments