Debian Codegraph @

rhino/testsrc/org/mozilla/javascript/tests/es5/ObjectKeysTest.java

raw symbols SCIP
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 /*
6 * Tests for the Object.keys(obj) method
7 */
8 package org.mozilla.javascript.tests.es5;
9 import org.mozilla.javascript.*;
10 import static org.mozilla.javascript.tests.Evaluator.eval;
11 import static org.junit.Assert.assertEquals;
12 import org.junit.Test;
13
14 public class ObjectKeysTest {
15
16 @Test
17 public void shouldReturnOnlyEnumerablePropertiesOfArg() {
18 NativeObject object = new NativeObject();
19 object.defineProperty("a", "1", ScriptableObject.EMPTY);
20 object.defineProperty("b", "2", ScriptableObject.EMPTY);
21 object.defineProperty("c", "3", ScriptableObject.DONTENUM);
22
23 Object result = eval("Object.keys(obj)", "obj", object);
24
25 NativeArray keys = (NativeArray) result;
26
27 assertEquals(2, keys.getLength());
28 assertEquals("a", keys.get(0, keys));
29 assertEquals("b", keys.get(1, keys));
30 }
31
32 }