Best JavaScript code snippet using ng-mocks
11.13.2-3.js
Source:11.13.2-3.js
1/* The contents of this file are subject to the Netscape Public2 * License Version 1.1 (the "License"); you may not use this file3 * except in compliance with the License. You may obtain a copy of4 * the License at http://www.mozilla.org/NPL/5 *6 * Software distributed under the License is distributed on an "AS7 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or8 * implied. See the License for the specific language governing9 * rights and limitations under the License.10 *11 * The Original Code is Mozilla Communicator client code, released March12 * 31, 1998.13 *14 * The Initial Developer of the Original Code is Netscape Communications15 * Corporation. Portions created by Netscape are16 * Copyright (C) 1998 Netscape Communications Corporation. All17 * Rights Reserved.18 *19 * Contributor(s): 20 * 21 */22 /**23 File Name: 11.13.2-4.js24 ECMA Section: 11.13.2 Compound Assignment: %=25 Description:26 *= /= %= += -= <<= >>= >>>= &= ^= |=27 11.13.2 Compound assignment ( op= )28 The production AssignmentExpression :29 LeftHandSideExpression @ = AssignmentExpression, where @ represents one of30 the operators indicated above, is evaluated as follows:31 1. Evaluate LeftHandSideExpression.32 2. Call GetValue(Result(1)).33 3. Evaluate AssignmentExpression.34 4. Call GetValue(Result(3)).35 5. Apply operator @ to Result(2) and Result(4).36 6. Call PutValue(Result(1), Result(5)).37 7. Return Result(5).38 Author: christine@netscape.com39 Date: 12 november 199740*/41 var SECTION = "11.13.2-3";42 var VERSION = "ECMA_1";43 startTest();44 var testcases = getTestCases();45 writeHeaderToLog( SECTION + " Compound Assignment: +=");46 test();47function getTestCases() {48 var array = new Array();49 var item = 0;50 // If either operand is NaN, result is NaN51 array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 %= VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 %= VAR2") );52 array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 %= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 %= VAR2; VAR1") );53 array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 %= VAR2") );54 array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 %= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 %= VAR2; VAR1") );55 array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 %= VAR2", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 %= VAR2") );56 array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 %= VAR2; VAR1", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 %= VAR2; VAR1") );57 // if the dividend is infinity or the divisor is zero or both, the result is NaN58 array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= Infinity; VAR1 %= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") );59 array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= -Infinity; VAR1 %= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") );60 array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2= Infinity; VAR1 %= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") );61 array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2=-Infinity; VAR1 %= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") );62 array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= Infinity; VAR2 %= VAR1", Number.NaN, eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR2 %= VAR1; VAR2") );63 array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= Infinity; VAR2 %= VAR1", Number.NaN, eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR2 %= VAR1; VAR2") );64 array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -Infinity; VAR2 %= VAR1", Number.NaN, eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 %= VAR1; VAR2") );65 array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -Infinity; VAR2 %= VAR1", Number.NaN, eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 %= VAR1; VAR2") );66 array[item++] = new TestCase( SECTION, "VAR1 = 1; VAR2= Infinity; VAR2 %= VAR1", Number.NaN, eval("VAR1 = 1; VAR2 = Number.POSITIVE_INFINITY; VAR2 %= VAR1; VAR2") );67 array[item++] = new TestCase( SECTION, "VAR1 = -1; VAR2= Infinity; VAR2 %= VAR1", Number.NaN, eval("VAR1 = -1; VAR2 = Number.POSITIVE_INFINITY; VAR2 %= VAR1; VAR2") );68 array[item++] = new TestCase( SECTION, "VAR1 = -1; VAR2= -Infinity; VAR2 %= VAR1", Number.NaN, eval("VAR1 = -1; VAR2 = Number.NEGATIVE_INFINITY; VAR2 %= VAR1; VAR2") );69 array[item++] = new TestCase( SECTION, "VAR1 = 1; VAR2= -Infinity; VAR2 %= VAR1", Number.NaN, eval("VAR1 = 1; VAR2 = Number.NEGATIVE_INFINITY; VAR2 %= VAR1; VAR2") );70 array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= 0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = 0; VAR2 = 0; VAR1 %= VAR2; VAR1") );71 array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = 0; VAR2 = -0; VAR1 %= VAR2; VAR1") );72 array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= 0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = -0; VAR2 = 0; VAR1 %= VAR2; VAR1") );73 array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = -0; VAR2 = -0; VAR1 %= VAR2; VAR1") );74 array[item++] = new TestCase( SECTION, "VAR1 = 1; VAR2= 0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = 1; VAR2 = 0; VAR1 %= VAR2; VAR1") );75 array[item++] = new TestCase( SECTION, "VAR1 = 1; VAR2= -0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = 1; VAR2 = -0; VAR1 %= VAR2; VAR1") );76 array[item++] = new TestCase( SECTION, "VAR1 = -1; VAR2= 0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = -1; VAR2 = 0; VAR1 %= VAR2; VAR1") );77 array[item++] = new TestCase( SECTION, "VAR1 = -1; VAR2= -0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = -1; VAR2 = -0; VAR1 %= VAR2; VAR1") );78 // if the dividend is finite and the divisor is an infinity, the result equals the dividend.79 array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= Infinity; VAR1 %= VAR2;VAR1", 0, eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") );80 array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= Infinity; VAR1 %= VAR2;VAR1", -0, eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") );81 array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -Infinity; VAR1 %= VAR2;VAR1", -0, eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") );82 array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -Infinity; VAR1 %= VAR2;VAR1", 0, eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") );83 array[item++] = new TestCase( SECTION, "VAR1 = 1; VAR2= Infinity; VAR1 %= VAR2;VAR1", 1, eval("VAR1 = 1; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") );84 array[item++] = new TestCase( SECTION, "VAR1 = -1; VAR2= Infinity; VAR1 %= VAR2;VAR1", -1, eval("VAR1 = -1; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") );85 array[item++] = new TestCase( SECTION, "VAR1 = -1; VAR2= -Infinity; VAR1 %= VAR2;VAR1", -1, eval("VAR1 = -1; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") );86 array[item++] = new TestCase( SECTION, "VAR1 = 1; VAR2= -Infinity; VAR1 %= VAR2;VAR1", 1, eval("VAR1 = 1; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") );87 // if the dividend is a zero and the divisor is finite, the result is the same as the dividend88 array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= 1; VAR1 %= VAR2; VAR1", 0, eval("VAR1 = 0; VAR2 = 1; VAR1 %= VAR2; VAR1") );89 array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= 1; VAR1 %= VAR2; VAR1", -0, eval("VAR1 = -0; VAR2 = 1; VAR1 %= VAR2; VAR1") );90 array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -1; VAR1 %= VAR2; VAR1", -0, eval("VAR1 = -0; VAR2 = -1; VAR1 %= VAR2; VAR1") );91 array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -1; VAR1 %= VAR2; VAR1", 0, eval("VAR1 = 0; VAR2 = -1; VAR1 %= VAR2; VAR1") );92 // string cases93 array[item++] = new TestCase( SECTION, "VAR1 = 1000; VAR2 = '10', VAR1 %= VAR2; VAR1", 0, eval("VAR1 = 1000; VAR2 = '10', VAR1 %= VAR2; VAR1") );94 array[item++] = new TestCase( SECTION, "VAR1 = '1000'; VAR2 = 10, VAR1 %= VAR2; VAR1", 0, eval("VAR1 = '1000'; VAR2 = 10, VAR1 %= VAR2; VAR1") );95/*96 array[item++] = new TestCase( SECTION, "VAR1 = 10; VAR2 = '0XFF', VAR1 %= VAR2", 2550, eval("VAR1 = 10; VAR2 = '0XFF', VAR1 %= VAR2") );97 array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 %= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 %= VAR2") );98 array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '255', VAR1 %= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '255', VAR1 %= VAR2") );99 array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '0XFF', VAR1 %= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '0XFF', VAR1 %= VAR2") );100 array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 %= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 %= VAR2") );101 // boolean cases102 array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = false; VAR1 %= VAR2", 0, eval("VAR1 = true; VAR2 = false; VAR1 %= VAR2") );103 array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = true; VAR1 %= VAR2", 1, eval("VAR1 = true; VAR2 = true; VAR1 %= VAR2") );104 // object cases105 array[item++] = new TestCase( SECTION, "VAR1 = new Boolean(true); VAR2 = 10; VAR1 %= VAR2;VAR1", 10, eval("VAR1 = new Boolean(true); VAR2 = 10; VAR1 %= VAR2; VAR1") );106 array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = 10; VAR1 %= VAR2; VAR1", 110, eval("VAR1 = new Number(11); VAR2 = 10; VAR1 %= VAR2; VAR1") );107 array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = new Number(10); VAR1 %= VAR2", 110, eval("VAR1 = new Number(11); VAR2 = new Number(10); VAR1 %= VAR2") );108 array[item++] = new TestCase( SECTION, "VAR1 = new String('15'); VAR2 = new String('0xF'); VAR1 %= VAR2", 255, eval("VAR1 = String('15'); VAR2 = new String('0xF'); VAR1 %= VAR2") );109*/110 return ( array );111}112function test() {113 for ( tc=0; tc < testcases.length; tc++ ) {114 testcases[tc].passed = writeTestCaseResult(115 testcases[tc].expect,116 testcases[tc].actual,117 testcases[tc].description +" = "+118 testcases[tc].actual );119 testcases[tc].reason %= ( testcases[tc].passed ) ? "" : "wrong value ";120 }121 stopTest();122 return ( testcases );...
11.13.2-2.js
Source:11.13.2-2.js
1/* The contents of this file are subject to the Netscape Public2 * License Version 1.1 (the "License"); you may not use this file3 * except in compliance with the License. You may obtain a copy of4 * the License at http://www.mozilla.org/NPL/5 *6 * Software distributed under the License is distributed on an "AS7 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or8 * implied. See the License for the specific language governing9 * rights and limitations under the License.10 *11 * The Original Code is Mozilla Communicator client code, released March12 * 31, 1998.13 *14 * The Initial Developer of the Original Code is Netscape Communications15 * Corporation. Portions created by Netscape are16 * Copyright (C) 1998 Netscape Communications Corporation. All17 * Rights Reserved.18 *19 * Contributor(s): 20 * 21 */22 /**23 File Name: 11.13.2-2js24 ECMA Section: 11.13.2 Compound Assignment: /=25 Description:26 *= /= %= += -= <<= >>= >>>= &= ^= |=27 11.13.2 Compound assignment ( op= )28 The production AssignmentExpression :29 LeftHandSideExpression @ = AssignmentExpression, where @ represents one of30 the operators indicated above, is evaluated as follows:31 1. Evaluate LeftHandSideExpression.32 2. Call GetValue(Result(1)).33 3. Evaluate AssignmentExpression.34 4. Call GetValue(Result(3)).35 5. Apply operator @ to Result(2) and Result(4).36 6. Call PutValue(Result(1), Result(5)).37 7. Return Result(5).38 Author: christine@netscape.com39 Date: 12 november 199740*/41 var SECTION = "11.13.2-2";42 var VERSION = "ECMA_1";43 startTest();44 var testcases = getTestCases();45 writeHeaderToLog( SECTION + " Compound Assignment: /=");46 test();47function getTestCases() {48 var array = new Array();49 var item = 0;50 // NaN cases51 array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 /= VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 /= VAR2") );52 array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 /= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 /= VAR2; VAR1") );53 array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 /= VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 /= VAR2") );54 array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 /= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 /= VAR2; VAR1") );55 array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 /= VAR2", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 /= VAR2") );56 array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 /= VAR2; VAR1", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 /= VAR2; VAR1") );57 // number cases58 array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=1; VAR1 /= VAR2", 0, eval("VAR1 = 0; VAR2=1; VAR1 /= VAR2") );59 array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=1; VAR1 /= VAR2;VAR1", 0, eval("VAR1 = 0; VAR2=1; VAR1 /= VAR2;VAR1") );60 array[item++] = new TestCase( SECTION, "VAR1 = 0xFF; VAR2 = 0xA, VAR1 /= VAR2", 25.5, eval("VAR1 = 0XFF; VAR2 = 0XA, VAR1 /= VAR2") );61 // special division cases62 array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= Infinity; VAR1 /= VAR2", 0, eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") );63 array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= Infinity; VAR1 /= VAR2", 0, eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") );64 array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -Infinity; VAR1 /= VAR2", 0, eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") );65 array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -Infinity; VAR1 /= VAR2", 0, eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") );66 array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= Infinity; VAR2 /= VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR2 /= VAR1; VAR2") );67 array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= Infinity; VAR2 /= VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR2 /= VAR1; VAR2") );68 array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -Infinity; VAR2 /= VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 /= VAR1; VAR2") );69 array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -Infinity; VAR2 /= VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 /= VAR1; VAR2") );70 array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= Infinity; VAR1 /= VAR2", Number.NaN, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") );71 array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= -Infinity; VAR1 /= VAR2", Number.NaN, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") );72 array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2= Infinity; VAR1 /= VAR2", Number.NaN, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") );73 array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2=-Infinity; VAR1 /= VAR2", Number.NaN, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") );74 array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= 0; VAR1 /= VAR2", Number.NaN, eval("VAR1 = 0; VAR2 = 0; VAR1 /= VAR2; VAR1") );75 array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -0; VAR1 /= VAR2", Number.NaN, eval("VAR1 = 0; VAR2 = -0; VAR1 /= VAR2; VAR1") );76 array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= 0; VAR1 /= VAR2", Number.NaN, eval("VAR1 = -0; VAR2 = 0; VAR1 /= VAR2; VAR1") );77 array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -0; VAR1 /= VAR2", Number.NaN, eval("VAR1 = -0; VAR2 = -0; VAR1 /= VAR2; VAR1") );78 array[item++] = new TestCase( SECTION, "VAR1 = 1; VAR2= 0; VAR1 /= VAR2", Number.POSITIVE_INFINITY, eval("VAR1 = 1; VAR2 = 0; VAR1 /= VAR2; VAR1") );79 array[item++] = new TestCase( SECTION, "VAR1 = 1; VAR2= -0; VAR1 /= VAR2", Number.NEGATIVE_INFINITY, eval("VAR1 = 1; VAR2 = -0; VAR1 /= VAR2; VAR1") );80 array[item++] = new TestCase( SECTION, "VAR1 = -1; VAR2= 0; VAR1 /= VAR2", Number.NEGATIVE_INFINITY, eval("VAR1 = -1; VAR2 = 0; VAR1 /= VAR2; VAR1") );81 array[item++] = new TestCase( SECTION, "VAR1 = -1; VAR2= -0; VAR1 /= VAR2", Number.POSITIVE_INFINITY, eval("VAR1 = -1; VAR2 = -0; VAR1 /= VAR2; VAR1") );82 // string cases83 array[item++] = new TestCase( SECTION, "VAR1 = 1000; VAR2 = '10', VAR1 /= VAR2; VAR1", 100, eval("VAR1 = 1000; VAR2 = '10', VAR1 /= VAR2; VAR1") );84 array[item++] = new TestCase( SECTION, "VAR1 = '1000'; VAR2 = 10, VAR1 /= VAR2; VAR1", 100, eval("VAR1 = '1000'; VAR2 = 10, VAR1 /= VAR2; VAR1") );85/*86 array[item++] = new TestCase( SECTION, "VAR1 = 10; VAR2 = '0XFF', VAR1 /= VAR2", 2550, eval("VAR1 = 10; VAR2 = '0XFF', VAR1 /= VAR2") );87 array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 /= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 /= VAR2") );88 array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '255', VAR1 /= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '255', VAR1 /= VAR2") );89 array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '0XFF', VAR1 /= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '0XFF', VAR1 /= VAR2") );90 array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 /= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 /= VAR2") );91 // boolean cases92 array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = false; VAR1 /= VAR2", 0, eval("VAR1 = true; VAR2 = false; VAR1 /= VAR2") );93 array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = true; VAR1 /= VAR2", 1, eval("VAR1 = true; VAR2 = true; VAR1 /= VAR2") );94 // object cases95 array[item++] = new TestCase( SECTION, "VAR1 = new Boolean(true); VAR2 = 10; VAR1 /= VAR2;VAR1", 10, eval("VAR1 = new Boolean(true); VAR2 = 10; VAR1 /= VAR2; VAR1") );96 array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = 10; VAR1 /= VAR2; VAR1", 110, eval("VAR1 = new Number(11); VAR2 = 10; VAR1 /= VAR2; VAR1") );97 array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = new Number(10); VAR1 /= VAR2", 110, eval("VAR1 = new Number(11); VAR2 = new Number(10); VAR1 /= VAR2") );98 array[item++] = new TestCase( SECTION, "VAR1 = new String('15'); VAR2 = new String('0xF'); VAR1 /= VAR2", 255, eval("VAR1 = String('15'); VAR2 = new String('0xF'); VAR1 /= VAR2") );99*/100 return ( array );101}102function test() {103 for ( tc=0; tc < testcases.length; tc++ ) {104 testcases[tc].passed = writeTestCaseResult(105 testcases[tc].expect,106 testcases[tc].actual,107 testcases[tc].description +" = "+108 testcases[tc].actual );109 testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";110 }111 stopTest();112 return ( testcases );...
MultipleStatementAlignmentUnitTest.js
Source:MultipleStatementAlignmentUnitTest.js
1// Valid2var1 = 'var1';3var10 = 'var1';4var100 = 'var1';5var1000 = 'var1';6// Invalid7var1 = 'var1';8var10 = 'var1';9var100 = 'var1';10var1000 = 'var1';11// Valid12var1 = 'var1';13var10 = 'var1';14var100 = 'var1';15var1000 = 'var1';16// Invalid17var1 = 'var1';18var10 = 'var1';19var100 = 'var1';20var1000 = 'var1';21// Valid22var1 += 'var1';23var10 += 'var1';24var100 += 'var1';25var1000 += 'var1';26// Invalid27var1 += 'var1';28var10+= 'var1';29var100 += 'var1';30var1000 += 'var1';31// Valid32var1 = 'var1';33var10 += 'var1';34var100 = 'var1';35var1000 += 'var1';36// Invalid37var1 = 'var1';38var10 += 'var1';39var100 = 'var1';40var1000+= 'var1';41// Valid42var1 += 'var1';43var10 += 'var1';44var100 += 'var1';45var1000 += 'var1';46// Invalid47var1 += 'var1';48var10 += 'var1';49var100 += 'var1';50var1000 += 'var1';51// Valid52var test = 100;53// InValid54var test = 100;55commentStart = phpcsFile.findPrevious();56commentEnd = this._phpcsFile;57expected += '...';58// Invalid59this.okButton = {};60content = {};61var buttonid = [this.id, '-positionFormats-add'].join('');62var buttonWidget = WidgetStore.get(buttonid);63var spinButtonid = [this.id, '-positionFormats-spinButton'].join('');64var spinButtonWidget = WidgetStore.get(spinButtonid);65var position = spinButtonWidget.getValue();66var posForamatsList = WidgetStore.get([self.id, '-positionFormats-list'].join(''));67dfx.stripTags = function(content, allowedTags)68{69 var match;70 var re = 'blah';71};72var contents += 'if (';73var conditions = array();74var foo = {};75foo.blah = 'blah';76var script = document.createElement('script');77script.onload = function()78{79 clearTimeout(t);80};81stream.match(stream.sol() ? /^\s*\/\/.*/ : /^\s+\/\/.*/);82function() {83 if (condition)84 foo = .4...
Using AI Code Generation
1var var1 = require('ng-mocks').var1;2var var2 = require('ng-mocks').var2;3var var3 = require('ng-mocks').var3;4var var4 = require('ng-mocks').var4;5var var5 = require('ng-mocks').var5;6var var6 = require('ng-mocks').var6;7var var7 = require('ng-mocks').var7;8var var8 = require('ng-mocks').var8;9var var9 = require('ng-mocks').var9;10var var10 = require('ng-mocks').var10;11var var11 = require('ng-mocks').var11;12var var12 = require('ng-mocks').var12;13var var13 = require('ng-mocks').var13;14var var14 = require('ng-mocks').var14;15var var15 = require('ng-mocks').var15;16var var16 = require('ng-mocks').var16;17var var17 = require('ng-mocks').var17;18var var18 = require('ng-mocks').var18;19var var19 = require('ng-mocks').var19;20var var20 = require('ng-mocks').var20;
Using AI Code Generation
1var var1 = require('ng-mocks').var1;2var1();3var var2 = require('ng-mocks').var2;4var2();5var var3 = require('ng-mocks').var3;6var3();7var var4 = require('ng-mocks').var4;8var4();9var var5 = require('ng-mocks').var5;10var5();11var var6 = require('ng-mocks').var6;12var6();13var var7 = require('ng-mocks').var7;14var7();15var var8 = require('ng-mocks').var8;16var8();17var var9 = require('ng-mocks').var9;18var9();19var var10 = require('ng-mocks').var10;20var10();21var var11 = require('ng-mocks').var11;22var11();23var var12 = require('ng-mocks').var12;24var12();25var var13 = require('ng-mocks').var13;26var13();27var var14 = require('ng-mocks').var14;28var14();29var var15 = require('ng-mocks').var15;30var15();
Using AI Code Generation
1import { var1 } from 'ng-mocks';2describe('MyComponent', () => {3 let component: MyComponent;4 let fixture: ComponentFixture<MyComponent>;5 beforeEach(async(() => {6 TestBed.configureTestingModule({7 })8 .compileComponents();9 }));10 beforeEach(() => {11 fixture = TestBed.createComponent(MyComponent);12 component = fixture.componentInstance;13 fixture.detectChanges();14 });15 it('should create', () => {16 expect(component).toBeTruthy();17 });18});
Using AI Code Generation
1var1.method1();2var1.method2();3var2.method1();4var2.method2();5var3.method1();6var3.method2();7describe('Test1', function() {8var ngMocks;9beforeEach(function() {10 ngMocks = {11 method1: function() {12 return 1;13 },14 method2: function() {15 return 2;16 }17 };18 module('ngMocks', function($provide) {19 $provide.value('ngMocks', ngMocks);20 });21});22it('should call method1', function() {23 expect(ngMocks.method1()).toEqual(1);24});25it('should call method2', function() {26 expect(ngMocks.method2()).toEqual(2);27});28});29describe('Test2', function() {30var ngMocks;31beforeEach(function() {32 ngMocks = {33 method1: function() {34 return 1;35 },36 method2: function() {37 return 2;38 }39 };40 module('ngMocks', function($provide) {41 $provide.value('ngMocks', ngMocks);42 });43});44it('should call method1', function() {45 expect(ngMocks.method1()).toEqual(1);46});47it('should call method2', function() {48 expect(ngMocks.method2()).toEqual(2);49});50});51describe('Test3', function() {52var ngMocks;53beforeEach(function() {54 ngMocks = {55 method1: function() {56 return 1;57 },58 method2: function() {59 return 2;60 }61 };62 module('ngMocks', function($provide) {63 $provide.value('ngMocks', ngMocks);64 });65});66it('should call method1', function() {67 expect(ngMocks.method1()).toEqual(1);68});69it('should call method2', function() {70 expect(ngMocks.method2()).toEqual(2);71});72});
Using AI Code Generation
1var var1 = require('ng-mocks');2var var2 = require('ng-mocks');3var1.var1();4var2.var2();5var var1 = require('ng-mocks');6var var2 = require('ng-mocks');7var1.var1();8var2.var2();9var var1 = require('ng-mocks');10var var2 = require('ng-mocks');11var1.var1();12var2.var2();13var var1 = require('ng-mocks');14var var2 = require('ng-mocks');15var1.var1();16var2.var2();17var var1 = require('ng-mocks');18var var2 = require('ng-mocks');19var1.var1();20var2.var2();21var var1 = require('ng-mocks');22var var2 = require('ng-mocks');23var1.var1();24var2.var2();25var var1 = require('ng-mocks');26var var2 = require('ng-mocks');27var1.var1();28var2.var2();29var var1 = require('ng-mocks');30var var2 = require('ng-mocks');31var1.var1();32var2.var2();33var var1 = require('ng-mocks');34var var2 = require('ng-mocks');35var1.var1();36var2.var2();37var var1 = require('ng-mocks');38var var2 = require('ng-mocks');39var1.var1();40var2.var2();41var var1 = require('ng-mocks
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!