diff options
Diffstat (limited to 'js/src/tests/test262/ch12/12.5')
23 files changed, 841 insertions, 0 deletions
diff --git a/js/src/tests/test262/ch12/12.5/S12.5_A1.1_T1.js b/js/src/tests/test262/ch12/12.5/S12.5_A1.1_T1.js new file mode 100644 index 000000000..ae2038c98 --- /dev/null +++ b/js/src/tests/test262/ch12/12.5/S12.5_A1.1_T1.js @@ -0,0 +1,53 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * 0, null, undefined, false, empty string, NaN in expression is evaluated to false + * + * @path ch12/12.5/S12.5_A1.1_T1.js + * @description Using "if" without "else" construction + */ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 + +if(0) + $ERROR('#1: 0 in expression is evaluated to false '); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if(false) + $ERROR('#2: false in expression is evaluated to false '); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if(null) + $ERROR('#3: null in expression is evaluated to false '); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if(undefined) + $ERROR('#4: undefined in expression is evaluated to false '); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#5 +if("") + $ERROR('#5: empty string in expression is evaluated to false '); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#6 +if(NaN) + $ERROR('#5: NaN in expression is evaluated to false '); +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch12/12.5/S12.5_A1.1_T2.js b/js/src/tests/test262/ch12/12.5/S12.5_A1.1_T2.js new file mode 100644 index 000000000..ba5d8e3cb --- /dev/null +++ b/js/src/tests/test262/ch12/12.5/S12.5_A1.1_T2.js @@ -0,0 +1,71 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * 0, null, undefined, false, empty string, NaN in expression is evaluated to false + * + * @path ch12/12.5/S12.5_A1.1_T2.js + * @description Using "if/else" construction + */ + +var c=0; +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if(0) + $ERROR('#1.1: 0 in expression is evaluated to false '); +else + c++; +if (c!=1) $ERROR('#1.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if(false) + $ERROR('#2.1: false in expression is evaluated to false '); +else + c++; +if (c!=2) $ERROR('#2.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if(null) + $ERROR('#3.1: null in expression is evaluated to false '); +else + c++; +if (c!=3) $ERROR('#3.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if(undefined) + $ERROR('#4.1: undefined in expression is evaluated to false '); +else + c++; +if (c!=4) $ERROR('#4.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#5 +if("") + $ERROR('#5.1: empty string in expression is evaluated to false '); +else + c++; +if (c!=5) $ERROR('#5.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#6 +if(NaN) + $ERROR('#6.1: NaN in expression is evaluated to false '); +else + c++; +if (c!=6) $ERROR('#6.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch12/12.5/S12.5_A1.2_T1.js b/js/src/tests/test262/ch12/12.5/S12.5_A1.2_T1.js new file mode 100644 index 000000000..19ba4cdd1 --- /dev/null +++ b/js/src/tests/test262/ch12/12.5/S12.5_A1.2_T1.js @@ -0,0 +1,73 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * 1, true, non-empty string and others in expression is evaluated to true when using operator "new" + * + * @path ch12/12.5/S12.5_A1.2_T1.js + * @description Using "if" without "else" construction + */ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if(!(new Number(1))) + $ERROR('#1: new 1 in expression is evaluated to true'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if(!(new Boolean(true))) + $ERROR('#2: new true in expression is evaluated to true'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if(!(new String("1"))) + $ERROR('#3: new "1" in expression is evaluated to true'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if(!(new String("A"))) + $ERROR('#4: new "A" in expression is evaluated to true'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#5 +if(!(new Boolean(false))) + $ERROR('#2: new false in expression is evaluated to true '); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#6 +if(!(new Number(NaN))) + $ERROR('#6: new NaN in expression is evaluated to true '); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#7 +if(!(new Number(null))) + $ERROR('#7: new null in expression is evaluated to true '); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#8 +if(!(new String(undefined))) + $ERROR('#8: new undefined in expression is evaluated to true '); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#9 +if(!(new String(""))) + $ERROR('#9: new empty string in expression is evaluated to true '); +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch12/12.5/S12.5_A1.2_T2.js b/js/src/tests/test262/ch12/12.5/S12.5_A1.2_T2.js new file mode 100644 index 000000000..b384311f1 --- /dev/null +++ b/js/src/tests/test262/ch12/12.5/S12.5_A1.2_T2.js @@ -0,0 +1,101 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * 1, true, non-empty string and others in expression is evaluated to true when using operator "new" + * + * @path ch12/12.5/S12.5_A1.2_T2.js + * @description Using "if/else" construction + */ + +var c=0; +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if(!(new Number(1))) + $ERROR('#1.1: new 1 in expression is evaluated to true'); +else + c++; +if (c!=1) $ERROR('#1.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if(!(new Boolean(true))) + $ERROR('#2.1: new true in expression is evaluated to true'); +else + c++; +if (c!=2) $ERROR('#2.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if(!(new String("1"))) + $ERROR('#3.1: new "1" in expression is evaluated to true'); +else + c++; +if (c!=3) $ERROR('#3.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if(!(new String("A"))) + $ERROR('#4.1: new "A" in expression is evaluated to true'); +else + c++; +if (c!=4) $ERROR('#4.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#5 +if(!(new Boolean(false))) + $ERROR('#5.1: new false in expression is evaluated to true '); +else + c++; +if (c!=5) $ERROR('#5.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#6 +if(!(new Number(NaN))) + $ERROR('#6.1: new NaN in expression is evaluated to true '); +else + c++; +if (c!=6) $ERROR('#6.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#7 +if(!(new Number(null))) + $ERROR('#7.1: new null in expression is evaluated to true '); +else + c++; +if (c!=7) $ERROR('#7.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#8 +if(!(new String(undefined))) + $ERROR('#8.1: new undefined in expression is evaluated to true '); +else + c++; +if (c!=8) $ERROR('#8.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#9 +if(!(new String(""))) + $ERROR('#9.1: new empty string in expression is evaluated to true '); +else + c++; +if (c!=9) $ERROR('#9.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch12/12.5/S12.5_A10_T1.js b/js/src/tests/test262/ch12/12.5/S12.5_A10_T1.js new file mode 100644 index 000000000..4995fe1c2 --- /dev/null +++ b/js/src/tests/test262/ch12/12.5/S12.5_A10_T1.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Function expession inside the "if" expression is allowed + * + * @path ch12/12.5/S12.5_A10_T1.js + * @description Using function expession(function __func(){return 0;}) inside the "if" expression + */ + +////////////////////////////////////////////////////////////////////////////// +//CHECK# +if(function __func(){return 0;}){ + ; +}else { + $ERROR('#1: Function expession inside the "if" expression is allowed'); +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch12/12.5/S12.5_A10_T2.js b/js/src/tests/test262/ch12/12.5/S12.5_A10_T2.js new file mode 100644 index 000000000..bcb187b08 --- /dev/null +++ b/js/src/tests/test262/ch12/12.5/S12.5_A10_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Function expession inside the "if" expression is allowed + * + * @path ch12/12.5/S12.5_A10_T2.js + * @description Using function expession "function __func(){return 0;}()" within "if" expression + */ + +////////////////////////////////////////////////////////////////////////////// +//CHECK# +if(function __func(){return 0;}()){ + $ERROR('#1: Function expession inside the if expression is allowed'); +}else { + ; +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch12/12.5/S12.5_A11.js b/js/src/tests/test262/ch12/12.5/S12.5_A11.js new file mode 100644 index 000000000..250b29f50 --- /dev/null +++ b/js/src/tests/test262/ch12/12.5/S12.5_A11.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * {} within the "if" expression is not allowed + * + * @path ch12/12.5/S12.5_A11.js + * @description Checking if execution of "if({1})" fails + * @negative + */ + +////////////////////////////////////////////////////////////////////////////// +//CHECK# +if({1}) + { + ; + }else + { + ; + } +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch12/12.5/S12.5_A12_T1.js b/js/src/tests/test262/ch12/12.5/S12.5_A12_T1.js new file mode 100644 index 000000000..43f858b09 --- /dev/null +++ b/js/src/tests/test262/ch12/12.5/S12.5_A12_T1.js @@ -0,0 +1,58 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Embedded "if/else" constructions are allowed + * + * @path ch12/12.5/S12.5_A12_T1.js + * @description Using embedded "if/else" into "if/else" constructions + */ + +//CHECK# 1 +if(true) + if (false) + $ERROR('#1.1: At embedded "if/else" constructions engine must select right branches'); + else + ; +else + if (true) + $ERROR('#1.2: At embedded "if/else" constructions engine must select right branches'); + else + $ERROR('#1.3: At embedded "if/else" constructions engine must select right branches'); + +//CHECK# 2 +if(true) + if (true) + ; + else + $ERROR('#2.1: At embedded "if/else" constructions engine must select right branches'); +else + if (true) + $ERROR('#2.2: At embedded "if/else" constructions engine must select right branches'); + else + $ERROR('#2.3: At embedded "if/else" constructions engine must select right branches'); + +//CHECK# 3 +if(false) + if (true) + $ERROR('#3.1: At embedded "if/else" constructions engine must select right branches'); + else + $ERROR('#3.2: At embedded "if/else" constructions engine must select right branches'); +else + if (true) + ; + else + $ERROR('#3.3: At embedded "if/else" constructions engine must select right branches'); + +//CHECK# 4 +if(false) + if (true) + $ERROR('#4.1: At embedded "if/else" constructions engine must select right branches'); + else + $ERROR('#4.2: At embedded "if/else" constructions engine must select right branches'); +else + if (false) + $ERROR('#4.3: At embedded "if/else" constructions engine must select right branches'); + else + ; + diff --git a/js/src/tests/test262/ch12/12.5/S12.5_A12_T2.js b/js/src/tests/test262/ch12/12.5/S12.5_A12_T2.js new file mode 100644 index 000000000..c9115994b --- /dev/null +++ b/js/src/tests/test262/ch12/12.5/S12.5_A12_T2.js @@ -0,0 +1,50 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Embedded "if/else" constructions are allowed + * + * @path ch12/12.5/S12.5_A12_T2.js + * @description Using embedded "if" into "if/else" constructions + */ + +//CHECK# 1 +if(true){ + if (false) + $ERROR('#1.1: At embedded "if/else" constructions engine must select right branches'); +} +else{ + if (true) + $ERROR('#1.2: At embedded "if/else" constructions engine must select right branches'); +} + +//CHECK# 2 +if(true){ + if (true) + ; +} +else{ + if (true) + $ERROR('#2.2: At embedded "if/else" constructions engine must select right branches'); +} + +//CHECK# 3 +if(false){ + if (true) + $ERROR('#3.1: At embedded "if/else" constructions engine must select right branches'); +} +else{ + if (true) + ; +} + +//CHECK# 4 +if(false){ + if (true) + $ERROR('#4.1: At embedded "if/else" constructions engine must select right branches'); +} +else{ + if (false) + $ERROR('#4.3: At embedded "if/else" constructions engine must select right branches'); +} + diff --git a/js/src/tests/test262/ch12/12.5/S12.5_A12_T3.js b/js/src/tests/test262/ch12/12.5/S12.5_A12_T3.js new file mode 100644 index 000000000..a17cff21f --- /dev/null +++ b/js/src/tests/test262/ch12/12.5/S12.5_A12_T3.js @@ -0,0 +1,38 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Embedded "if/else" constructions are allowed + * + * @path ch12/12.5/S12.5_A12_T3.js + * @description Using embedded "if/else" into "if" without "else" constructions + */ + +//CHECK# 1 +if(true) + if (false) + $ERROR('#1.1: At embedded "if/else" constructions engine must select right branches'); + else + ; + +//CHECK# 2 +if(true) + if (true) + ; + else + $ERROR('#2.1: At embedded "if/else" constructions engine must select right branches'); + +//CHECK# 3 +if(false) + if (true) + $ERROR('#3.1: At embedded "if/else" constructions engine must select right branches'); + else + $ERROR('#3.2: At embedded "if/else" constructions engine must select right branches'); + +//CHECK# 4 +if(false) + if (true) + $ERROR('#4.1: At embedded "if/else" constructions engine must select right branches'); + else + $ERROR('#4.2: At embedded "if/else" constructions engine must select right branches'); + diff --git a/js/src/tests/test262/ch12/12.5/S12.5_A12_T4.js b/js/src/tests/test262/ch12/12.5/S12.5_A12_T4.js new file mode 100644 index 000000000..03f643d62 --- /dev/null +++ b/js/src/tests/test262/ch12/12.5/S12.5_A12_T4.js @@ -0,0 +1,33 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Embedded "if/else" constructions are allowed + * + * @path ch12/12.5/S12.5_A12_T4.js + * @description Using embedded "if" into "if" constructions + */ + +//CHECK# 1 +if(true) + if (false) + $ERROR('#1.1: At embedded "if/else" constructions engine must select right branches'); + +//CHECK# 2 +var c=0; +if(true) + if (true) + c=2; +if (c!==2) + $ERROR('#2: At embedded "if/else" constructions engine must select right branches'); + +//CHECK# 3 +if(false) + if (true) + $ERROR('#3.1: At embedded "if/else" constructions engine must select right branches'); + +//CHECK# 4 +if(false) + if (true) + $ERROR('#4.1: At embedded "if/else" constructions engine must select right branches'); + diff --git a/js/src/tests/test262/ch12/12.5/S12.5_A1_T1.js b/js/src/tests/test262/ch12/12.5/S12.5_A1_T1.js new file mode 100644 index 000000000..df6f327d4 --- /dev/null +++ b/js/src/tests/test262/ch12/12.5/S12.5_A1_T1.js @@ -0,0 +1,39 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * 1, true, non-empty string in expression is evaluated to true + * + * @path ch12/12.5/S12.5_A1_T1.js + * @description Using "if" without "else" construction + */ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if(!(1)) + $ERROR('#1: 1 in expression is evaluated to true'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if(!(true)) + $ERROR('#2: true in expression is evaluated to true'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if(!("1")) + $ERROR('#3: "1" in expression is evaluated to true'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if(!("A")) + $ERROR('#4: "A" in expression is evaluated to true'); +// +////////////////////////////////////////////////////////////////////////////// + + diff --git a/js/src/tests/test262/ch12/12.5/S12.5_A1_T2.js b/js/src/tests/test262/ch12/12.5/S12.5_A1_T2.js new file mode 100644 index 000000000..ea952a930 --- /dev/null +++ b/js/src/tests/test262/ch12/12.5/S12.5_A1_T2.js @@ -0,0 +1,52 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * 1, true, non-empty string in expression is evaluated to true + * + * @path ch12/12.5/S12.5_A1_T2.js + * @description Using "if/else" construction + */ + +var c=0; +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if(!(1)) + $ERROR('#1.1: 1 in expression is evaluated to true'); +else + c++; +if (c!=1) $ERROR('#1.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if(!(true)) + $ERROR('#2.1: true in expression is evaluated to true'); +else + c++; +if (c!=2) $ERROR('#2.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if(!("1")) + $ERROR('#3.1: "1" in expression is evaluated to true'); +else + c++; +if (c!=3) $ERROR('#3.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if(!("A")) + $ERROR('#4.1: "A" in expression is evaluated to true'); +else + c++; +if (c!=4) $ERROR('#4.2: else branch don`t execute'); +// +////////////////////////////////////////////////////////////////////////////// + + diff --git a/js/src/tests/test262/ch12/12.5/S12.5_A2.js b/js/src/tests/test262/ch12/12.5/S12.5_A2.js new file mode 100644 index 000000000..c953c29cd --- /dev/null +++ b/js/src/tests/test262/ch12/12.5/S12.5_A2.js @@ -0,0 +1,13 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * In the "if" Statement eval in Expression is admitted + * + * @path ch12/12.5/S12.5_A2.js + * @description Checking by using eval "eval("true")" + * @negative + */ + +if (eval("true")) $FAIL('#1: In the "if" Statement eval as Expression is admitted'); + diff --git a/js/src/tests/test262/ch12/12.5/S12.5_A3.js b/js/src/tests/test262/ch12/12.5/S12.5_A3.js new file mode 100644 index 000000000..3eb41d59b --- /dev/null +++ b/js/src/tests/test262/ch12/12.5/S12.5_A3.js @@ -0,0 +1,35 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * When the production "IfStatement: if ( Expression ) Statement else Statement" is evaluated, Expression is evaluated first + * + * @path ch12/12.5/S12.5_A3.js + * @description The Expression is "(function(){throw 1})()" + */ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + if ((function(){throw 1})()) abracadabra +} catch (e) { + if (e !== 1) { + $ERROR('#1: Exception === 1. Actual: Exception ==='+ e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +try { + if ((function(){throw 1})()) abracadabra; else blablachat; +} catch (e) { + if (e !== 1) { + $ERROR('#2: Exception === 1. Actual: Exception ==='+ e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + + diff --git a/js/src/tests/test262/ch12/12.5/S12.5_A4.js b/js/src/tests/test262/ch12/12.5/S12.5_A4.js new file mode 100644 index 000000000..73babcfea --- /dev/null +++ b/js/src/tests/test262/ch12/12.5/S12.5_A4.js @@ -0,0 +1,37 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * When the production "IfStatement: if ( Expression ) Statement else Statement" is evaluated, Statement(s) is(are) evaluated second + * + * @path ch12/12.5/S12.5_A4.js + * @description The first statement is "(function(){throw "instatement"})()" + */ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + if (true) (function(){throw "instatement"})(); + $FAIL("#1 failed") +} catch (e) { + if (e !== "instatement") { + $ERROR('#1: Exception === "instatement". Actual: Exception ==='+ e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +try { + if (false) (function(){throw "truebranch"})(); (function(){throw "missbranch"})(); + $FAIL("#2 failed") +} catch (e) { + if (e !== "missbranch") { + $ERROR('#2: Exception === "missbranch". Actual: Exception ==='+ e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + + diff --git a/js/src/tests/test262/ch12/12.5/S12.5_A5.js b/js/src/tests/test262/ch12/12.5/S12.5_A5.js new file mode 100644 index 000000000..72c334a67 --- /dev/null +++ b/js/src/tests/test262/ch12/12.5/S12.5_A5.js @@ -0,0 +1,48 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * FunctionDeclaration inside the "if" Expression is evaluated as true and function will not be declarated + * + * @path ch12/12.5/S12.5_A5.js + * @description The "if" Expression is "function __func(){throw "FunctionExpression";}" + */ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + __func=__func; + $ERROR('#1: "__func=__func" lead to throwing exception'); +} catch (e) { + ; +} +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +try { + if(function __func(){throw "FunctionExpression";}) (function(){throw "TrueBranch"})(); else (function(){"MissBranch"})(); +} catch (e) { + if (e !== "TrueBranch") { + $ERROR('#2: Exception ==="TrueBranch". Actual: Exception ==='+ e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +try { + __func=__func; + $ERROR('#3: "__func=__func" lead to throwing exception'); +} catch (e) { + ; +} +// +////////////////////////////////////////////////////////////////////////////// + + + + diff --git a/js/src/tests/test262/ch12/12.5/S12.5_A6_T1.js b/js/src/tests/test262/ch12/12.5/S12.5_A6_T1.js new file mode 100644 index 000000000..76aabe63c --- /dev/null +++ b/js/src/tests/test262/ch12/12.5/S12.5_A6_T1.js @@ -0,0 +1,17 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * In the If statement expression must be enclosed in braces + * + * @path ch12/12.5/S12.5_A6_T1.js + * @description Checking if execution of "if true" fails + * @negative + */ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if true; +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch12/12.5/S12.5_A6_T2.js b/js/src/tests/test262/ch12/12.5/S12.5_A6_T2.js new file mode 100644 index 000000000..1b6f383ab --- /dev/null +++ b/js/src/tests/test262/ch12/12.5/S12.5_A6_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * In the If statement expression must be enclosed in braces + * + * @path ch12/12.5/S12.5_A6_T2.js + * @description Checking if execution of "if false" fails + * @negative + */ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if false; +// +////////////////////////////////////////////////////////////////////////////// + + diff --git a/js/src/tests/test262/ch12/12.5/S12.5_A7.js b/js/src/tests/test262/ch12/12.5/S12.5_A7.js new file mode 100644 index 000000000..f450d6aea --- /dev/null +++ b/js/src/tests/test262/ch12/12.5/S12.5_A7.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * In the "if" statement empty statement is allowed and is evaluated to "undefined" + * + * @path ch12/12.5/S12.5_A7.js + * @description Checking by using eval "eval("if(1);"))" + */ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var __evaluated = eval("if(1);"); + if (__evaluated !== undefined) { + $ERROR('#1: __evaluated === undefined. Actual: __evaluated ==='+ __evaluated ); + } + +} catch (e) { + $ERROR('#1.1: "__evaluated = eval("if(1);")" does not lead to throwing exception'); + +} +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch12/12.5/S12.5_A8.js b/js/src/tests/test262/ch12/12.5/S12.5_A8.js new file mode 100644 index 000000000..7a2d4b9c6 --- /dev/null +++ b/js/src/tests/test262/ch12/12.5/S12.5_A8.js @@ -0,0 +1,17 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * In the "if" Statement empty expression is not allowed + * + * @path ch12/12.5/S12.5_A8.js + * @description Checking if execution of "if()" fails + * @negative + */ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if(); +// +////////////////////////////////////////////////////////////////////////////// + diff --git a/js/src/tests/test262/ch12/12.5/browser.js b/js/src/tests/test262/ch12/12.5/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/test262/ch12/12.5/browser.js diff --git a/js/src/tests/test262/ch12/12.5/shell.js b/js/src/tests/test262/ch12/12.5/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/test262/ch12/12.5/shell.js |