|
| 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 | + |
| 16 | +var test_symbol = Symbol ('Test'); |
| 17 | + |
| 18 | +var obj = {}; |
| 19 | + |
| 20 | +assert ((test_symbol in obj) === false); |
| 21 | + |
| 22 | +obj[test_symbol] = 'value'; |
| 23 | + |
| 24 | +assert ((test_symbol in obj) === true); |
| 25 | +assert (obj[test_symbol] === 'value'); |
| 26 | + |
| 27 | + |
| 28 | +var array = []; |
| 29 | + |
| 30 | +assert ((test_symbol in array) === false); |
| 31 | + |
| 32 | +array[test_symbol] = 'value'; |
| 33 | + |
| 34 | +assert ((test_symbol in array) === true); |
| 35 | +assert (array[test_symbol] === 'value'); |
| 36 | + |
| 37 | + |
| 38 | +assert ((test_symbol in Symbol) === false); |
| 39 | + |
| 40 | +try { |
| 41 | + test_symbol in test_symbol; |
| 42 | + assert (false); |
| 43 | +} catch (ex) { |
| 44 | + assert (ex instanceof TypeError); |
| 45 | +} |
| 46 | + |
| 47 | +try { |
| 48 | + test_symbol in 3; |
| 49 | + assert (false); |
| 50 | +} catch (ex) { |
| 51 | + assert (ex instanceof TypeError); |
| 52 | +} |
| 53 | + |
| 54 | +try { |
| 55 | + test_symbol in 'Test'; |
| 56 | + assert (false); |
| 57 | +} catch (ex) { |
| 58 | + assert (ex instanceof TypeError); |
| 59 | +} |
0 commit comments