mirror of https://github.com/svaarala/duktape.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.1 KiB
44 lines
1.1 KiB
12 years ago
|
/*
|
||
|
* Redeclare a global configurable plain (data) property, E5.1 change.
|
||
|
*/
|
||
|
|
||
|
/*===
|
||
|
function
|
||
|
true true false
|
||
12 years ago
|
function
|
||
12 years ago
|
true true false
|
||
12 years ago
|
123
|
||
12 years ago
|
===*/
|
||
|
|
||
|
/* RegExp is configurable.
|
||
|
*
|
||
|
* Re-declaring it should change the binding, and make the new property
|
||
|
* writable, non-configurable, and enumerable. The property becomes
|
||
|
* non-configurable because configurableBindings=false in E5.1 Section 10.5,
|
||
|
* 5.e.iii for Program code.
|
||
|
*/
|
||
|
|
||
|
var desc;
|
||
|
var indirectEval = eval;
|
||
|
var global = indirectEval("this"); // for Node
|
||
|
|
||
|
// Note: since declarations are hoisted, the RegExp declaration below
|
||
12 years ago
|
// will already have taken effect here. The original RegExp binding
|
||
|
// is writable and configurable, but not enumerable.
|
||
12 years ago
|
|
||
|
print(typeof RegExp);
|
||
|
desc = Object.getOwnPropertyDescriptor(global, 'RegExp');
|
||
|
print(desc.writable, desc.enumerable, desc.configurable);
|
||
|
|
||
|
function RegExp() {
|
||
|
return 123;
|
||
|
}
|
||
|
|
||
|
// just checking that order does not matter
|
||
|
print(typeof RegExp);
|
||
|
desc = Object.getOwnPropertyDescriptor(global, 'RegExp');
|
||
|
print(desc.writable, desc.enumerable, desc.configurable);
|
||
|
|
||
12 years ago
|
print(RegExp());
|
||
|
|