A
Asen Bozhilov
I write for own usage simple test for some case in ES
implementations.
var ESImplement = {
_global : this,
functionStatement : function()
{
var code = [
'{',
'function f(){}',
'}'
].join('');
try {
eval(code);
return true;
}catch(e) {}
return false;
},
namedFunctionExpression : function()
{
var NFE;
return typeof NFE == 'undefined';
(function NFE(){});
},
variableObjectPrototype : function()
{
Object.prototype.x = true;
var x = false,
f = function(){
return x;
};
f = f();
delete Object.prototype.x;
return f;
},
globalObjectPrototype : function()
{
Object.prototype.x = true;
var x = false;
with(this._global)
{
var res = x;
}
delete Object.prototype.x;
return res;
},
objectLiteralUseObjectConstructor : function()
{
var o = Object,
res = true;
Object = null;
try {
({});
res = false;
}catch(e){}
Object = o;
return res;
},
arrayLiteralUseArrayConstructor : function()
{
var a = Array,
res = true;
Array = null;
try {
([]);
res = false;
}catch(e){};
Array = a;
return res;
},
forInToObjectExpression : function()
{
try {
for(var i in null);
return false;
}catch(e) {}
return true;
}
};
var IO = {
println : function(str)
{
if (typeof window != 'undefined' && typeof document !=
'undefined')
{
window.document.writeln(str);
}
else if (typeof WScript != 'undefined')
{
WScript.Echo(str);
}
else if (typeof println == 'function')
{
println(str);
}
}
};
Any suggestions, correction and addition are welcome.
Interesting part is `variableObjectPrototype` in DMDScript
implementation. They used object with [[Prototype]] which refer
`Object.prototype`. DMD have the same behavior and with Global
Object.
Regards.
implementations.
var ESImplement = {
_global : this,
functionStatement : function()
{
var code = [
'{',
'function f(){}',
'}'
].join('');
try {
eval(code);
return true;
}catch(e) {}
return false;
},
namedFunctionExpression : function()
{
var NFE;
return typeof NFE == 'undefined';
(function NFE(){});
},
variableObjectPrototype : function()
{
Object.prototype.x = true;
var x = false,
f = function(){
return x;
};
f = f();
delete Object.prototype.x;
return f;
},
globalObjectPrototype : function()
{
Object.prototype.x = true;
var x = false;
with(this._global)
{
var res = x;
}
delete Object.prototype.x;
return res;
},
objectLiteralUseObjectConstructor : function()
{
var o = Object,
res = true;
Object = null;
try {
({});
res = false;
}catch(e){}
Object = o;
return res;
},
arrayLiteralUseArrayConstructor : function()
{
var a = Array,
res = true;
Array = null;
try {
([]);
res = false;
}catch(e){};
Array = a;
return res;
},
forInToObjectExpression : function()
{
try {
for(var i in null);
return false;
}catch(e) {}
return true;
}
};
var IO = {
println : function(str)
{
if (typeof window != 'undefined' && typeof document !=
'undefined')
{
window.document.writeln(str);
}
else if (typeof WScript != 'undefined')
{
WScript.Echo(str);
}
else if (typeof println == 'function')
{
println(str);
}
}
};
Any suggestions, correction and addition are welcome.
Interesting part is `variableObjectPrototype` in DMDScript
implementation. They used object with [[Prototype]] which refer
`Object.prototype`. DMD have the same behavior and with Global
Object.
Regards.