Debian Codegraph @

rhino/testsrc/org/mozilla/javascript/tests/es5/ObjectGetOwnPropertyNamesTest.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.getOwnPropertyNames(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 ObjectGetOwnPropertyNamesTest {
15
16 @Test
17 public void testShouldReturnAllPropertiesOfArg() {
18 NativeObject object = new NativeObject();
19 object.defineProperty("a", "1", ScriptableObject.EMPTY);
20 object.defineProperty("b", "2", ScriptableObject.DONTENUM);
21
22 Object result = eval("Object.getOwnPropertyNames(obj)", "obj", object);
23
24 NativeArray names = (NativeArray) result;
25
26 assertEquals(2, names.getLength());
27 assertEquals("a", names.get(0, names));
28 assertEquals("b", names.get(1, names));
29 }
30
31 }