Thu, 06 Feb 2014 17:44:37 +0530
8033763: Add tests to assert map identity of certain objects
Reviewed-by: hannesw, lagergren
1.1 --- a/make/build.xml Mon Jan 20 19:51:54 2014 +0530 1.2 +++ b/make/build.xml Thu Feb 06 17:44:37 2014 +0530 1.3 @@ -279,6 +279,11 @@ 1.4 permission java.security.AllPermission; 1.5 }; 1.6 1.7 +grant codeBase "file:/${basedir}/test/script/maptests/*" { 1.8 + permission java.io.FilePermission "${basedir}/test/script/maptests/*","read"; 1.9 + permission java.lang.RuntimePermission "nashorn.debugMode"; 1.10 +}; 1.11 + 1.12 grant codeBase "file:/${basedir}/test/script/basic/*" { 1.13 permission java.io.FilePermission "${basedir}/test/script/-", "read"; 1.14 permission java.io.FilePermission "$${user.dir}", "read";
2.1 --- a/make/project.properties Mon Jan 20 19:51:54 2014 +0530 2.2 +++ b/make/project.properties Thu Feb 06 17:44:37 2014 +0530 2.3 @@ -112,6 +112,7 @@ 2.4 test.dir=test 2.5 test.script.dir=test/script 2.6 test.basic.dir=test/script/basic 2.7 +test.maptests.dir=test/script/maptests 2.8 test.error.dir=test/script/error 2.9 test.sandbox.dir=test/script/sandbox 2.10 test.trusted.dir=test/script/trusted 2.11 @@ -121,7 +122,7 @@ 2.12 testjfx.dir=${test.script.dir}/jfx 2.13 2.14 test-sys-prop.test.dir=${test.dir} 2.15 -test-sys-prop.test.js.roots=${test.basic.dir} ${test.error.dir} ${test.sandbox.dir} ${test.trusted.dir} 2.16 +test-sys-prop.test.js.roots=${test.basic.dir} ${test.maptests.dir} ${test.error.dir} ${test.sandbox.dir} ${test.trusted.dir} 2.17 test-sys-prop.test262.suite.dir=${test262.suite.dir} 2.18 test-sys-prop.es5conform.testcases.dir=${test.external.dir}/ES5Conform/TestCases 2.19 test-sys-prop.test.basic.dir=${test.basic.dir} 2.20 @@ -264,7 +265,7 @@ 2.21 run.test.jvmsecurityargs=-Xverify:all -Djava.security.manager -Djava.security.policy=${basedir}/build/nashorn.policy 2.22 2.23 # VM options for script tests with @fork option 2.24 -test-sys-prop.test.fork.jvm.options=${run.test.jvmargs.main} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs} 2.25 +test-sys-prop.test.fork.jvm.options=${run.test.jvmargs.main} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs} -cp ${run.test.classpath} 2.26 2.27 # path of rhino.jar for benchmarks 2.28 rhino.jar=
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/test/script/currently-failing/gettersetter.js Thu Feb 06 17:44:37 2014 +0530 3.3 @@ -0,0 +1,48 @@ 3.4 +/* 3.5 + * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. 3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.7 + * 3.8 + * This code is free software; you can redistribute it and/or modify it 3.9 + * under the terms of the GNU General Public License version 2 only, as 3.10 + * published by the Free Software Foundation. 3.11 + * 3.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 3.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 3.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 3.15 + * version 2 for more details (a copy is included in the LICENSE file that 3.16 + * accompanied this code). 3.17 + * 3.18 + * You should have received a copy of the GNU General Public License version 3.19 + * 2 along with this work; if not, write to the Free Software Foundation, 3.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 3.21 + * 3.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 3.23 + * or visit www.oracle.com if you need additional information or have any 3.24 + * questions. 3.25 + */ 3.26 + 3.27 +/** 3.28 + * @test 3.29 + * @option -Dnashorn.debug=true 3.30 + * @fork 3.31 + */ 3.32 + 3.33 +load(__DIR__ + "maputil.js"); 3.34 + 3.35 +function Foo() { 3.36 + return { 3.37 + get foo() { return 42; }, 3.38 + set foo(x) {} 3.39 + } 3.40 +} 3.41 + 3.42 +var obj1 = Foo(); 3.43 +var obj2 = Foo(); 3.44 + 3.45 +assertSameMap(obj1, obj2, "Object literals before change"); 3.46 + 3.47 +Object.defineProperty(obj2, "foo", { get: function() { return 'hello' } }); 3.48 +assertSameMap(obj1, obj2); 3.49 + 3.50 +Object.defineProperty(obj2, "foo", { set: function(x) { print(x) } }); 3.51 +assertSameMap(obj1, obj2);
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/test/script/maptests/builtins.js Thu Feb 06 17:44:37 2014 +0530 4.3 @@ -0,0 +1,58 @@ 4.4 +/* 4.5 + * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. 4.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.7 + * 4.8 + * This code is free software; you can redistribute it and/or modify it 4.9 + * under the terms of the GNU General Public License version 2 only, as 4.10 + * published by the Free Software Foundation. 4.11 + * 4.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 4.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 4.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 4.15 + * version 2 for more details (a copy is included in the LICENSE file that 4.16 + * accompanied this code). 4.17 + * 4.18 + * You should have received a copy of the GNU General Public License version 4.19 + * 2 along with this work; if not, write to the Free Software Foundation, 4.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 4.21 + * 4.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 4.23 + * or visit www.oracle.com if you need additional information or have any 4.24 + * questions. 4.25 + */ 4.26 + 4.27 +/** 4.28 + * @test 4.29 + * @option -Dnashorn.debug=true 4.30 + * @fork 4.31 + */ 4.32 + 4.33 +load(__DIR__ + "maputil.js"); 4.34 + 4.35 +// check that builtin objects share property map 4.36 + 4.37 +assertSameMap(new Boolean(true), new Boolean(false)); 4.38 +assertSameMap(new Number(3), new Number(Math.PI)); 4.39 +assertSameMap(new String('hello'), new String('world')); 4.40 +assertSameMap(new Object(), new Object()); 4.41 +assertSameMap(/hello/, /world/); 4.42 +// try w/without regexp flags 4.43 +assertSameMap(/hello/i, /world/g); 4.44 +assertSameMap(new Date(), new Date()); 4.45 +assertSameMap(new Date(2000, 1, 1), new Date(1972, 5, 6)); 4.46 +assertSameMap(Function(), Function()); 4.47 +assertSameMap(Function("x", "return x"), Function("x", "return x*x")); 4.48 +assertSameMap(new Error(), new Error()); 4.49 +assertSameMap(new Error('foo'), new Error('bar')); 4.50 +assertSameMap(new EvalError(), new EvalError()); 4.51 +assertSameMap(new EvalError('foo'), new EvalError('bar')); 4.52 +assertSameMap(new RangeError(), new RangeError()); 4.53 +assertSameMap(new RangeError('foo'), new RangeError('bar')); 4.54 +assertSameMap(new ReferenceError(), new ReferenceError()); 4.55 +assertSameMap(new ReferenceError('foo'), new ReferenceError('bar')); 4.56 +assertSameMap(new SyntaxError(), new SyntaxError()); 4.57 +assertSameMap(new SyntaxError('foo'), new SyntaxError('bar')); 4.58 +assertSameMap(new TypeError(), new TypeError()); 4.59 +assertSameMap(new TypeError('foo'), new TypeError('bar')); 4.60 +assertSameMap(new URIError(), new URIError()); 4.61 +assertSameMap(new URIError('foo'), new URIError('bar'));
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/test/script/maptests/constructor.js Thu Feb 06 17:44:37 2014 +0530 5.3 @@ -0,0 +1,36 @@ 5.4 +/* 5.5 + * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. 5.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.7 + * 5.8 + * This code is free software; you can redistribute it and/or modify it 5.9 + * under the terms of the GNU General Public License version 2 only, as 5.10 + * published by the Free Software Foundation. 5.11 + * 5.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 5.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 5.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 5.15 + * version 2 for more details (a copy is included in the LICENSE file that 5.16 + * accompanied this code). 5.17 + * 5.18 + * You should have received a copy of the GNU General Public License version 5.19 + * 2 along with this work; if not, write to the Free Software Foundation, 5.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 5.21 + * 5.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 5.23 + * or visit www.oracle.com if you need additional information or have any 5.24 + * questions. 5.25 + */ 5.26 + 5.27 +/** 5.28 + * @test 5.29 + * @option -Dnashorn.debug=true 5.30 + * @fork 5.31 + */ 5.32 + 5.33 +load(__DIR__ + "point.js"); 5.34 + 5.35 +// use constructor defined in a different script file 5.36 +// These objects should share the map 5.37 +assertSameMap(new Point(2, 3), new Point(43, 23)); 5.38 +assertSameMap(new Point(), new Point()); 5.39 +assertSameMap(new Point(), new Point(3, 1));
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/test/script/maptests/maputil.js Thu Feb 06 17:44:37 2014 +0530 6.3 @@ -0,0 +1,38 @@ 6.4 +/* 6.5 + * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. 6.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6.7 + * 6.8 + * This code is free software; you can redistribute it and/or modify it 6.9 + * under the terms of the GNU General Public License version 2 only, as 6.10 + * published by the Free Software Foundation. 6.11 + * 6.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 6.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 6.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 6.15 + * version 2 for more details (a copy is included in the LICENSE file that 6.16 + * accompanied this code). 6.17 + * 6.18 + * You should have received a copy of the GNU General Public License version 6.19 + * 2 along with this work; if not, write to the Free Software Foundation, 6.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 6.21 + * 6.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 6.23 + * or visit www.oracle.com if you need additional information or have any 6.24 + * questions. 6.25 + */ 6.26 + 6.27 +/** 6.28 + * @subtest 6.29 + */ 6.30 + 6.31 +function assertSameMap(obj1, obj2, msg) { 6.32 + if (! Debug.identical(Debug.map(obj1), Debug.map(obj2))) { 6.33 + fail(obj1.constructor + " instances don't share map"); 6.34 + } 6.35 +} 6.36 + 6.37 +function assertNotSameMap(obj1, obj2, msg) { 6.38 + if (Debug.identical(Debug.map(obj1), Debug.map(obj2))) { 6.39 + fail(obj1.constructor + " and " + obj2.constructor + " instances share map"); 6.40 + } 6.41 +}
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 7.2 +++ b/test/script/maptests/object_create.js Thu Feb 06 17:44:37 2014 +0530 7.3 @@ -0,0 +1,40 @@ 7.4 +/* 7.5 + * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. 7.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7.7 + * 7.8 + * This code is free software; you can redistribute it and/or modify it 7.9 + * under the terms of the GNU General Public License version 2 only, as 7.10 + * published by the Free Software Foundation. 7.11 + * 7.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 7.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 7.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 7.15 + * version 2 for more details (a copy is included in the LICENSE file that 7.16 + * accompanied this code). 7.17 + * 7.18 + * You should have received a copy of the GNU General Public License version 7.19 + * 2 along with this work; if not, write to the Free Software Foundation, 7.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 7.21 + * 7.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 7.23 + * or visit www.oracle.com if you need additional information or have any 7.24 + * questions. 7.25 + */ 7.26 + 7.27 +/** 7.28 + * @test 7.29 + * @option -Dnashorn.debug=true 7.30 + * @fork 7.31 + */ 7.32 + 7.33 +load(__DIR__ + "maputil.js"); 7.34 + 7.35 +// Objects created by Object.create 7.36 +var obj1 = Object.create(Object.prototype); 7.37 +var obj2 = Object.create(Object.prototype); 7.38 +assertSameMap(obj1, obj2); 7.39 + 7.40 +var proto = { foo: 233 }; 7.41 +obj1 = Object.create(proto); 7.42 +obj2 = Object.create(proto); 7.43 +assertSameMap(obj1, obj2);
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 8.2 +++ b/test/script/maptests/object_literals.js Thu Feb 06 17:44:37 2014 +0530 8.3 @@ -0,0 +1,46 @@ 8.4 +/* 8.5 + * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. 8.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 8.7 + * 8.8 + * This code is free software; you can redistribute it and/or modify it 8.9 + * under the terms of the GNU General Public License version 2 only, as 8.10 + * published by the Free Software Foundation. 8.11 + * 8.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 8.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 8.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 8.15 + * version 2 for more details (a copy is included in the LICENSE file that 8.16 + * accompanied this code). 8.17 + * 8.18 + * You should have received a copy of the GNU General Public License version 8.19 + * 2 along with this work; if not, write to the Free Software Foundation, 8.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 8.21 + * 8.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 8.23 + * or visit www.oracle.com if you need additional information or have any 8.24 + * questions. 8.25 + */ 8.26 + 8.27 +/** 8.28 + * @test 8.29 + * @option -Dnashorn.debug=true 8.30 + * @fork 8.31 + */ 8.32 + 8.33 +load(__DIR__ + "maputil.js"); 8.34 + 8.35 +// Object literals created at the same callsite 8.36 +function makeObject() { 8.37 + return { foo: 34 } 8.38 +} 8.39 +assertSameMap(makeObject(), makeObject()); 8.40 + 8.41 +function makeObject2() { 8.42 + return { foo: 42, bar: 'hello' } 8.43 +} 8.44 +assertSameMap(makeObject2(), makeObject2()); 8.45 + 8.46 +// Object literals created at different callsites 8.47 +assertSameMap({}, {}); 8.48 +assertSameMap({foo: 4}, {foo: 'hello'}); 8.49 +assertSameMap({foo: 34, bar: 'fdgd'}, {foo: 'world', bar: 54});
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/test/script/maptests/point.js Thu Feb 06 17:44:37 2014 +0530 9.3 @@ -0,0 +1,49 @@ 9.4 +/* 9.5 + * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. 9.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9.7 + * 9.8 + * This code is free software; you can redistribute it and/or modify it 9.9 + * under the terms of the GNU General Public License version 2 only, as 9.10 + * published by the Free Software Foundation. 9.11 + * 9.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 9.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 9.15 + * version 2 for more details (a copy is included in the LICENSE file that 9.16 + * accompanied this code). 9.17 + * 9.18 + * You should have received a copy of the GNU General Public License version 9.19 + * 2 along with this work; if not, write to the Free Software Foundation, 9.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 9.21 + * 9.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 9.23 + * or visit www.oracle.com if you need additional information or have any 9.24 + * questions. 9.25 + */ 9.26 + 9.27 + 9.28 +/** 9.29 + * @subtest 9.30 + */ 9.31 + 9.32 +function Point(x, y) { 9.33 + this.x =x; this.y =y; 9.34 +} 9.35 + 9.36 +Point.prototype.toString = function() { 9.37 + return "(" + this.x + "," + this.y + ")"; 9.38 +} 9.39 + 9.40 +Point.prototype.modulus = function() { 9.41 + return Math.sqrt(this.x*this.x + this.y*this.y); 9.42 +} 9.43 + 9.44 +Point.prototype.argument = function() { 9.45 + return Math.atan2(this.y, this.x); 9.46 +} 9.47 + 9.48 +load(__DIR__ + "maputil.js"); 9.49 + 9.50 +assertSameMap(new Point(2, 3), new Point(43, 23)); 9.51 +assertSameMap(new Point(), new Point()); 9.52 +assertSameMap(new Point(), new Point(3, 1));
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 10.2 +++ b/test/script/maptests/property_add.js Thu Feb 06 17:44:37 2014 +0530 10.3 @@ -0,0 +1,46 @@ 10.4 +/* 10.5 + * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. 10.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 10.7 + * 10.8 + * This code is free software; you can redistribute it and/or modify it 10.9 + * under the terms of the GNU General Public License version 2 only, as 10.10 + * published by the Free Software Foundation. 10.11 + * 10.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 10.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 10.15 + * version 2 for more details (a copy is included in the LICENSE file that 10.16 + * accompanied this code). 10.17 + * 10.18 + * You should have received a copy of the GNU General Public License version 10.19 + * 2 along with this work; if not, write to the Free Software Foundation, 10.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 10.21 + * 10.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 10.23 + * or visit www.oracle.com if you need additional information or have any 10.24 + * questions. 10.25 + */ 10.26 + 10.27 +/** 10.28 + * @test 10.29 + * @option -Dnashorn.debug=true 10.30 + * @fork 10.31 + */ 10.32 + 10.33 +load(__DIR__ + "maputil.js"); 10.34 + 10.35 +function Foo() {} 10.36 + 10.37 +var obj1 = new Foo(); 10.38 +var obj2 = new Foo(); 10.39 + 10.40 +assertSameMap(obj1, obj2); 10.41 + 10.42 +// property addition at same callsite 10.43 +function addX(obj, val) { 10.44 + obj.x = val; 10.45 +} 10.46 +addX(obj1, 3); 10.47 +addX(obj2, 'hello'); 10.48 + 10.49 +assertSameMap(obj1, obj2);
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 11.2 +++ b/test/script/maptests/property_delete.js Thu Feb 06 17:44:37 2014 +0530 11.3 @@ -0,0 +1,48 @@ 11.4 +/* 11.5 + * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. 11.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 11.7 + * 11.8 + * This code is free software; you can redistribute it and/or modify it 11.9 + * under the terms of the GNU General Public License version 2 only, as 11.10 + * published by the Free Software Foundation. 11.11 + * 11.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 11.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11.15 + * version 2 for more details (a copy is included in the LICENSE file that 11.16 + * accompanied this code). 11.17 + * 11.18 + * You should have received a copy of the GNU General Public License version 11.19 + * 2 along with this work; if not, write to the Free Software Foundation, 11.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 11.21 + * 11.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 11.23 + * or visit www.oracle.com if you need additional information or have any 11.24 + * questions. 11.25 + */ 11.26 + 11.27 +/** 11.28 + * @test 11.29 + * @option -Dnashorn.debug=true 11.30 + * @fork 11.31 + */ 11.32 + 11.33 +load(__DIR__ + "maputil.js"); 11.34 + 11.35 +function Foo() { 11.36 + this.x = 33; 11.37 +} 11.38 + 11.39 +var obj1 = new Foo(); 11.40 +var obj2 = new Foo(); 11.41 + 11.42 +assertSameMap(obj1, obj2); 11.43 + 11.44 +// property deletion at same callsite 11.45 +function deleteX(obj) { 11.46 + delete obj.x; 11.47 +} 11.48 +deleteX(obj1); 11.49 +deleteX(obj2); 11.50 + 11.51 +assertSameMap(obj1, obj2);
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 12.2 +++ b/test/script/maptests/proto.js Thu Feb 06 17:44:37 2014 +0530 12.3 @@ -0,0 +1,56 @@ 12.4 +/* 12.5 + * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. 12.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 12.7 + * 12.8 + * This code is free software; you can redistribute it and/or modify it 12.9 + * under the terms of the GNU General Public License version 2 only, as 12.10 + * published by the Free Software Foundation. 12.11 + * 12.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 12.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12.15 + * version 2 for more details (a copy is included in the LICENSE file that 12.16 + * accompanied this code). 12.17 + * 12.18 + * You should have received a copy of the GNU General Public License version 12.19 + * 2 along with this work; if not, write to the Free Software Foundation, 12.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 12.21 + * 12.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 12.23 + * or visit www.oracle.com if you need additional information or have any 12.24 + * questions. 12.25 + */ 12.26 + 12.27 +/** 12.28 + * @test 12.29 + * @option -Dnashorn.debug=true 12.30 + * @fork 12.31 + */ 12.32 + 12.33 +load(__DIR__ + "maputil.js"); 12.34 + 12.35 +// add/delete property to proto (direct/indirect) should 12.36 +// not affect the property map of the objects 12.37 + 12.38 +var proto2 = { foo: 334 } 12.39 +var proto = Object.create(proto2); 12.40 +proto.bar = "hello"; 12.41 + 12.42 +var obj1 = Object.create(proto); 12.43 +var obj2 = Object.create(proto); 12.44 + 12.45 +assertSameMap(obj1, obj2); 12.46 + 12.47 +proto.newX = 'world'; 12.48 +assertSameMap(obj1, obj2); 12.49 + 12.50 +delete proto.newX; 12.51 +assertSameMap(obj1, obj2); 12.52 + 12.53 +proto2.newX = "foo"; 12.54 +assertSameMap(obj1, obj2); 12.55 + 12.56 +delete proto2.newX; 12.57 +assertSameMap(obj1, obj2); 12.58 + 12.59 +