2011-09-07 08:35:18 +02:00
|
|
|
// Copyright 2009 the Sputnik authors. All rights reserved.
|
|
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
|
|
|
2014-07-22 01:09:02 +02:00
|
|
|
/*---
|
2018-01-05 18:26:51 +01:00
|
|
|
info: |
|
2014-07-22 01:09:02 +02:00
|
|
|
The function call Function(…) is equivalent to the object creation expression
|
|
|
|
new Function(…) with the same arguments.
|
2014-07-25 00:41:42 +02:00
|
|
|
es5id: 15.3.1_A1_T1
|
2014-07-22 01:09:02 +02:00
|
|
|
description: Create simple functions and check returned values
|
|
|
|
---*/
|
2011-09-07 08:35:18 +02:00
|
|
|
|
|
|
|
var f = Function("return arguments[0];");
|
|
|
|
|
|
|
|
//CHECK#1
|
2018-02-15 21:49:19 +01:00
|
|
|
if (!(f instanceof Function)) {
|
2011-09-07 08:35:18 +02:00
|
|
|
$ERROR('#1: f instanceof Function');
|
|
|
|
}
|
|
|
|
|
|
|
|
//CHECK#2
|
|
|
|
if (f(1) !== 1) {
|
|
|
|
$ERROR('#2: f(1) !== 1');
|
|
|
|
}
|
|
|
|
|
|
|
|
var g = new Function("return arguments[0];");
|
|
|
|
|
|
|
|
|
|
|
|
//CHECK#3
|
|
|
|
if (!(g instanceof Function)) {
|
|
|
|
$ERROR('#3: g instanceof Function');
|
|
|
|
}
|
|
|
|
|
|
|
|
//CHECK#4
|
|
|
|
if (g("A") !== "A") {
|
|
|
|
$ERROR('#4: g("A") !== "A"');
|
|
|
|
}
|
|
|
|
|
|
|
|
//CHECK#5
|
|
|
|
if (g("A") !== f("A")) {
|
|
|
|
$ERROR('#5: g("A") !== f("A")');
|
|
|
|
}
|