Best JavaScript code snippet using testcafe
f1.js
Source:f1.js  
...143        const v= [144            bigInt.zero,145            q.minus(1),146            q.minus(2),147            q.minus(1).shiftRight(1),148            q.minus(1).shiftRight(1).add(1),149            q.minus(1).shiftRight(1).add(2),150            q.minus(1).shiftRight(1).minus(1),151            q.minus(1).shiftRight(1).minus(2),152            bigInt(bigInt("F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0", 16)),153            bigInt(bigInt("10101010101010101010101010101010", 16)),154            bigInt(bigInt("FF00FF00FF00FF00FF00FF00FF00FF00", 16)),155            bigInt(bigInt("11001100110011001100110011001100", 16)),156            bigInt(bigInt("F0F0F0F0F0F0F0F0", 16)),157            bigInt(bigInt("1010101010101010", 16)),158            bigInt(bigInt("FF00FF00FF00FF00", 16)),159            bigInt(bigInt("1100110011001100", 16)),160            bigInt(2),161            bigInt.one,162        ];163        const pA = f1.allocInt();164        const pB = f1.allocInt();165        const pC = f1.allocInt();166        const pR = f1.allocInt();167        for (let i=0; i<v.length; i++) {168            for (let j=1; j<v.length; j++) {169                const expected_c = v[i].divide(v[j]);170                const expected_r = v[i].mod(v[j]);171                f1.putInt(pA, v[i]);172                f1.putInt(pB, v[j]);173                f1.int_div(pA, pB, pC, pR);174                const c = f1.getInt(pC);175                const r = f1.getInt(pR);176                assert(expected_r.equals(r));177                assert(expected_c.equals(c));178            }179        }180    });181    it("It should do a basic reduction 1", async () => {182        const f1 = await buildF1(bigInt("FFFFFFFFFFFFFFFF",16));183        const pA = f1.allocInt2(bigInt(0x10000000000000000));184        const pC = f1.allocInt();185        f1.f1m_mReduct(pA, pC);186        const c = f1.getInt(pC);187        assert.equal(c, 1);188    });189    it("It should do a basic reduction 2", async () => {190        const q = bigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617");191        const f1 = await buildF1(q);192        const a = bigInt("10000242871839275222246405745257275088548364400416034343698204186575808495617");193        const b = bigInt("10000242871839275222246405745257275088548364400416034343698204186575808234523");194        const pA = f1.allocInt(a);195        const pB = f1.allocInt(b);196        const pC = f1.allocInt2();197        const pD = f1.allocInt();198        f1.int_mul(pA, pB, pC);199        const c = f1.getInt2(pC);200        f1.f1m_mReduct(pC, pD);201        const d = f1.getInt(pD);202        const r = bigInt.one.shiftLeft(256).mod(q);203        const r2 = r.times(r).mod(q);204        const pR2 = f1.allocInt(r2);205        const pE = f1.allocInt2();206        f1.int_mul(pD, pR2, pE);207        const pF = f1.allocInt();208        f1.f1m_mReduct(pE, pF);209        const f = f1.getInt2(pF);210        assert(a.times(b).mod(q).equals(f.mod(q)));211    });212    it("It should do a basic reduction 3", async () => {213        const q = bigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617");214        const f1 = await buildF1(q);215        const a = bigInt("10000242871839275222246405745257275088548364400416034343698204186575808495617");216        const b = bigInt("10000242871839275222246405745257275088548364400416034343698204186575808234523");217        const pA = f1.allocInt(a);218        const pB = f1.allocInt(b);219        const pC = f1.allocInt();220        f1.f1_mul(pA, pB, pC);221        const c = f1.getInt2(pC);222        assert(a.times(b).mod(q).equals(c.mod(q)));223    });224    it("It should do various test in zq Snarks modules", async () => {225        const q = bigInt("21888242871839275222246405745257275088696311157297823662689037894645226208583");226        const f1 = await buildF1(q);227        const v= [228            q.minus(1),229            q.minus(2),230            q.minus(1).shiftRight(1),231            q.minus(1).shiftRight(1).add(1),232            q.minus(1).shiftRight(1).add(2),233            q.minus(1).shiftRight(1).minus(1),234            q.minus(1).shiftRight(1).minus(2),235            bigInt(2),236            bigInt.one,237            bigInt.zero238        ];239        const pA = f1.allocInt();240        const pB = f1.allocInt();241        const pC = f1.allocInt();242        let c;243        for (let i=0; i<v.length; i++) {244            for (let j=0; j<5; j++) {245                f1.putInt(pA, v[i]);246                f1.putInt(pB, v[j]);247                // eq248                assert.equal( f1.int_eq(pA,pB), (i==j));249                // add250                f1.f1_add(pA, pB, pC);251                c = f1.getInt2(pC);252                assert(c.equals(v[i].add(v[j]).mod(q)));253                // sub254                f1.f1_sub(pA, pB, pC);255                c = f1.getInt2(pC);256                let s = v[i].minus(v[j]).mod(q);257                if (s.isNegative()) s=s.add(q);258                assert(c.equals(s));259                // mul260                f1.f1_mul(pA, pB, pC);261                c = f1.getInt2(pC);262                assert(c.equals(v[i].times(v[j]).mod(q)));263            }264        }265    });266    it("It should do a test", async () => {267        const q = bigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617");268        const f1 = await buildF1(q);269        const t = f1.test_F1(1000000);270        console.log(t);271    }).timeout(10000000);272    it("Should test to montgomery", async () => {273        const q = bigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617");274        const f1 = await buildF1(q);275        const r = bigInt(11);276        const pR = f1.allocInt(r);277        const pRes = f1.allocInt();278        const pRes2 = f1.allocInt();279        f1.f1m_toMontgomery(pR, pRes);280        const res = f1.getInt(pRes);281        f1.f1m_fromMontgomery(pRes, pRes2);282        const res2 = f1.getInt(pRes2);283        assert(res.equals(r.times( bigInt.one.shiftLeft(256)).mod(q)));284        assert(res2.equals(r));285    });286    it("Should convert back and forth montgomery", async () => {287        const q = bigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617");288        const v= [289            q.minus(1),290            q.minus(2),291            q.minus(1).shiftRight(1),292            q.minus(1).shiftRight(1).add(1),293            q.minus(1).shiftRight(1).add(2),294            q.minus(1).shiftRight(1).minus(1),295            q.minus(1).shiftRight(1).minus(2),296            bigInt(2),297            bigInt.one,298            bigInt.zero299        ];300        const f1 = await buildF1(q);301        const pA = f1.allocInt();302        for (let i=0; i<v.length; i++) {303            f1.putInt(pA, v[i]);304            f1.f1m_toMontgomery(pA, pA);305            f1.f1m_fromMontgomery(pA, pA);306            const a = f1.getInt(pA);307            assert(v[i].equals(a));308        }309    });310    it("Should do inverse", async () => {311        const q = bigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617");312        const v= [313            bigInt.one,314            q.minus(1),315            q.minus(2),316            q.minus(1).shiftRight(1),317            q.minus(1).shiftRight(1).add(1),318            q.minus(1).shiftRight(1).add(2),319            q.minus(1).shiftRight(1).minus(1),320            q.minus(1).shiftRight(1).minus(2),321            bigInt(2),322        ];323        const f1 = await buildF1(q);324        const pA = f1.allocInt();325        const pB = f1.allocInt();326        const pQ = f1.allocInt();327        f1.putInt(pQ, q);328        for (let i=0; i<v.length; i++) {329            f1.putInt(pA, v[i]);330            f1.int_inverseMod(pA, pQ, pB);331            const b = f1.getInt(pB);332            assert(b.equals(v[i].modInv(q)));333        }334    });335    it("Should do inverse in montgomery", async () => {336        const q = bigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617");337        const v= [338            bigInt.one,339            q.minus(1),340            q.minus(2),341            q.minus(1).shiftRight(1),342            q.minus(1).shiftRight(1).add(1),343            q.minus(1).shiftRight(1).add(2),344            q.minus(1).shiftRight(1).minus(1),345            q.minus(1).shiftRight(1).minus(2),346            bigInt(2),347        ];348        const f1 = await buildF1(q);349        const pA = f1.allocInt();350        const pB = f1.allocInt();351        const pC = f1.allocInt();352        for (let i=0; i<v.length; i++) {353            f1.putInt(pA, v[i]);354            f1.f1m_toMontgomery(pA, pA);355            f1.f1m_inverse(pA, pB);356            f1.f1m_mul(pA, pB, pC);357            f1.f1m_fromMontgomery(pC, pC);358            const c = f1.getInt(pC);359            assert(c.equals(1));360        }361    });362    it("Test Neg", async () => {363        const q = bigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617");364        const v= [365            bigInt.one,366            q.minus(1),367            q.minus(2),368            q.minus(1).shiftRight(1),369            q.minus(1).shiftRight(1).add(1),370            q.minus(1).shiftRight(1).add(2),371            q.minus(1).shiftRight(1).minus(1),372            q.minus(1).shiftRight(1).minus(2),373            bigInt(2),374        ];375        const f1 = await buildF1(q);376        const pA = f1.allocInt();377        for (let i=0; i<v.length; i++) {378            f1.putInt(pA, v[i]);379            f1.f1m_neg(pA);380            f1.f1m_neg(pA);381            const a = f1.getInt(pA);382            assert(a.equals(v[i]));383        }384    });385    it("It should profile int", async () => {386        let start,end,time;387        const q = bigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617");388        const A=q.minus(1);389        const B=q.minus(1).shiftRight(1);390        const pbF1m = await buildProtoboard((module) => {391            buildF1m(module, q);392            buildTest(module, "f1m_mul");393            buildTest(module, "f1m_mulOld");394        }, 32);395        const pA = pbF1m.alloc();396        const pB = pbF1m.alloc();397        const pC = pbF1m.alloc();398        pbF1m.set(pA, A);399        pbF1m.f1m_toMontgomery(pA, pA);400        pbF1m.set(pB, B);401        pbF1m.f1m_toMontgomery(pB, pB);402        start = new Date().getTime();403        pbF1m.test_f1m_mul(pA, pB, pC, 50000000);...actions_command_editor.js
Source:actions_command_editor.js  
1//startgnumessage//2/*3This file is part of Vodka.4Vodka is free software: you can redistribute it and/or modify5it under the terms of the GNU General Public License as published by6the Free Software Foundation, either version 3 of the License, or7(at your option) any later version.8Vodka is distributed in the hope that it will be useful,9but WITHOUT ANY WARRANTY; without even the implied warranty of10MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the11GNU General Public License for more details.12You should have received a copy of the GNU General Public License13along with Vodka.  If not, see <https://www.gnu.org/licenses/>.14*/15//endgnumessage//16//testname// actions_command_editor17//startdescription//18/*19When you're in the command editor, some keys should keep you in the editor, while others should kick you out. This test verifies various keys that would kick you out, or not kick you out.20*/21//enddescription//22//testspec// |Shift|~|c|a|r|Shift|!|Shift|Tab|Shift|~|c|a|r|Shift|@|Shift|Tab|Shift|~|c|a|r|Shift|#|Shift|Tab|Shift|~|c|a|r|Shift|$|Shift|Tab|Shift|~|c|a|r|Shift|%|Shift|Tab|Shift|~|c|a|r|Shift|^|Shift|Tab|Shift|~|c|a|r|Shift|&|Shift|Tab|Shift|~|c|a|r|Shift|*|Enter|Shift|Shift|Shift|Shift|Shift|Shift|~|c|Shift|)|Shift|Tab|Shift|~|c|Enter|Shift|Shift|Shift|Shift|~|c|Enter|Shift|~|c|Enter|Shift|Shift|Shift|Shift|)23//starttest//24var harness = require('../testharness');25var testactions = [];26testactions.push({type:'keydown',code:'ShiftRight'});27testactions.push({type:'keydown',code:'Backquote'});28testactions.push({type:'keyup',code:'Backquote'});29testactions.push({type:'keyup',code:'ShiftRight'});30testactions.push({type:'keydown',code:'KeyC'});31testactions.push({type:'keyup',code:'KeyC'});32testactions.push({type:'keydown',code:'KeyA'});33testactions.push({type:'keydown',code:'KeyR'});34testactions.push({type:'keyup',code:'KeyA'});35testactions.push({type:'keyup',code:'KeyR'});36testactions.push({type:'keydown',code:'ShiftRight'});37testactions.push({type:'keydown',code:'Digit1'});38testactions.push({type:'keyup',code:'Digit1'});39testactions.push({type:'keyup',code:'ShiftRight'});40testactions.push({type:'keydown',code:'ShiftRight'});41testactions.push({type:'keydown',code:'Tab'});42testactions.push({type:'keyup',code:'Tab'});43testactions.push({type:'keyup',code:'ShiftRight'});44testactions.push({type:'keydown',code:'ShiftRight'});45testactions.push({type:'keydown',code:'Backquote'});46testactions.push({type:'keyup',code:'Backquote'});47testactions.push({type:'keyup',code:'ShiftRight'});48testactions.push({type:'keydown',code:'KeyC'});49testactions.push({type:'keyup',code:'KeyC'});50testactions.push({type:'keydown',code:'KeyA'});51testactions.push({type:'keydown',code:'KeyR'});52testactions.push({type:'keyup',code:'KeyA'});53testactions.push({type:'keyup',code:'KeyR'});54testactions.push({type:'keydown',code:'ShiftRight'});55testactions.push({type:'keydown',code:'Digit2'});56testactions.push({type:'keyup',code:'Digit2'});57testactions.push({type:'keyup',code:'ShiftRight'});58testactions.push({type:'keydown',code:'ShiftRight'});59testactions.push({type:'keydown',code:'Tab'});60testactions.push({type:'keyup',code:'Tab'});61testactions.push({type:'keyup',code:'ShiftRight'});62testactions.push({type:'keydown',code:'ShiftRight'});63testactions.push({type:'keydown',code:'Backquote'});64testactions.push({type:'keyup',code:'Backquote'});65testactions.push({type:'keyup',code:'ShiftRight'});66testactions.push({type:'keydown',code:'KeyC'});67testactions.push({type:'keyup',code:'KeyC'});68testactions.push({type:'keydown',code:'KeyA'});69testactions.push({type:'keydown',code:'KeyR'});70testactions.push({type:'keyup',code:'KeyA'});71testactions.push({type:'keyup',code:'KeyR'});72testactions.push({type:'keydown',code:'ShiftRight'});73testactions.push({type:'keydown',code:'Digit3'});74testactions.push({type:'keyup',code:'Digit3'});75testactions.push({type:'keyup',code:'ShiftRight'});76testactions.push({type:'keydown',code:'ShiftRight'});77testactions.push({type:'keydown',code:'Tab'});78testactions.push({type:'keyup',code:'Tab'});79testactions.push({type:'keyup',code:'ShiftRight'});80testactions.push({type:'keydown',code:'ShiftRight'});81testactions.push({type:'keydown',code:'Backquote'});82testactions.push({type:'keyup',code:'Backquote'});83testactions.push({type:'keyup',code:'ShiftRight'});84testactions.push({type:'keydown',code:'KeyC'});85testactions.push({type:'keyup',code:'KeyC'});86testactions.push({type:'keydown',code:'KeyA'});87testactions.push({type:'keydown',code:'KeyR'});88testactions.push({type:'keyup',code:'KeyA'});89testactions.push({type:'keyup',code:'KeyR'});90testactions.push({type:'keydown',code:'ShiftRight'});91testactions.push({type:'keydown',code:'Digit4'});92testactions.push({type:'keyup',code:'Digit4'});93testactions.push({type:'keyup',code:'ShiftRight'});94testactions.push({type:'keydown',code:'Tab'});95testactions.push({type:'keyup',code:'Tab'});96testactions.push({type:'keydown',code:'Enter'});97testactions.push({type:'keyup',code:'Enter'});98testactions.push({type:'keydown',code:'ShiftRight'});99testactions.push({type:'keydown',code:'Tab'});100testactions.push({type:'keyup',code:'Tab'});101testactions.push({type:'keyup',code:'ShiftRight'});102testactions.push({type:'keydown',code:'ShiftRight'});103testactions.push({type:'keydown',code:'Backquote'});104testactions.push({type:'keyup',code:'Backquote'});105testactions.push({type:'keyup',code:'ShiftRight'});106testactions.push({type:'keydown',code:'KeyC'});107testactions.push({type:'keyup',code:'KeyC'});108testactions.push({type:'keydown',code:'KeyA'});109testactions.push({type:'keydown',code:'KeyR'});110testactions.push({type:'keyup',code:'KeyA'});111testactions.push({type:'keyup',code:'KeyR'});112testactions.push({type:'keydown',code:'ShiftRight'});113testactions.push({type:'keydown',code:'Digit5'});114testactions.push({type:'keyup',code:'Digit5'});115testactions.push({type:'keyup',code:'ShiftRight'});116testactions.push({type:'keydown',code:'ShiftRight'});117testactions.push({type:'keydown',code:'Tab'});118testactions.push({type:'keyup',code:'Tab'});119testactions.push({type:'keyup',code:'ShiftRight'});120testactions.push({type:'keydown',code:'ShiftRight'});121testactions.push({type:'keydown',code:'Backquote'});122testactions.push({type:'keyup',code:'Backquote'});123testactions.push({type:'keyup',code:'ShiftRight'});124testactions.push({type:'keydown',code:'KeyC'});125testactions.push({type:'keyup',code:'KeyC'});126testactions.push({type:'keydown',code:'KeyA'});127testactions.push({type:'keydown',code:'KeyR'});128testactions.push({type:'keyup',code:'KeyA'});129testactions.push({type:'keyup',code:'KeyR'});130testactions.push({type:'keydown',code:'ShiftRight'});131testactions.push({type:'keydown',code:'Digit6'});132testactions.push({type:'keyup',code:'Digit6'});133testactions.push({type:'keyup',code:'ShiftRight'});134testactions.push({type:'keydown',code:'ShiftRight'});135testactions.push({type:'keydown',code:'Tab'});136testactions.push({type:'keyup',code:'Tab'});137testactions.push({type:'keyup',code:'ShiftRight'});138testactions.push({type:'keydown',code:'ShiftRight'});139testactions.push({type:'keydown',code:'Backquote'});140testactions.push({type:'keyup',code:'Backquote'});141testactions.push({type:'keyup',code:'ShiftRight'});142testactions.push({type:'keydown',code:'KeyC'});143testactions.push({type:'keyup',code:'KeyC'});144testactions.push({type:'keydown',code:'KeyA'});145testactions.push({type:'keydown',code:'KeyR'});146testactions.push({type:'keyup',code:'KeyA'});147testactions.push({type:'keyup',code:'KeyR'});148testactions.push({type:'keydown',code:'ShiftRight'});149testactions.push({type:'keydown',code:'Digit7'});150testactions.push({type:'keyup',code:'Digit7'});151testactions.push({type:'keyup',code:'ShiftRight'});152testactions.push({type:'keydown',code:'ShiftRight'});153testactions.push({type:'keydown',code:'Tab'});154testactions.push({type:'keyup',code:'Tab'});155testactions.push({type:'keyup',code:'ShiftRight'});156testactions.push({type:'keydown',code:'ShiftRight'});157testactions.push({type:'keydown',code:'Backquote'});158testactions.push({type:'keyup',code:'Backquote'});159testactions.push({type:'keyup',code:'ShiftRight'});160testactions.push({type:'keydown',code:'KeyC'});161testactions.push({type:'keyup',code:'KeyC'});162testactions.push({type:'keydown',code:'KeyA'});163testactions.push({type:'keydown',code:'KeyR'});164testactions.push({type:'keyup',code:'KeyA'});165testactions.push({type:'keyup',code:'KeyR'});166testactions.push({type:'keydown',code:'ShiftRight'});167testactions.push({type:'keydown',code:'Digit8'});168testactions.push({type:'keyup',code:'Digit8'});169testactions.push({type:'keyup',code:'ShiftRight'});170testactions.push({type:'keydown',code:'ShiftRight'});171testactions.push({type:'keydown',code:'Equal'});172testactions.push({type:'keyup',code:'Equal'});173testactions.push({type:'keyup',code:'ShiftRight'});174testactions.push({type:'keydown',code:'Equal'});175testactions.push({type:'keyup',code:'Equal'});176testactions.push({type:'keydown',code:'Minus'});177testactions.push({type:'keyup',code:'Minus'});178testactions.push({type:'keydown',code:'Slash'});179testactions.push({type:'keyup',code:'Slash'});180testactions.push({type:'keydown',code:'ShiftRight'});181testactions.push({type:'keydown',code:'Comma'});182testactions.push({type:'keyup',code:'Comma'});183testactions.push({type:'keyup',code:'ShiftRight'});184testactions.push({type:'keydown',code:'ShiftRight'});185testactions.push({type:'keydown',code:'Period'});186testactions.push({type:'keyup',code:'Period'});187testactions.push({type:'keyup',code:'ShiftRight'});188testactions.push({type:'keydown',code:'Enter'});189testactions.push({type:'keyup',code:'Enter'});190testactions.push({type:'keydown',code:'ArrowRight'});191testactions.push({type:'keyup',code:'ArrowRight'});192testactions.push({type:'keydown',code:'ArrowRight'});193testactions.push({type:'keyup',code:'ArrowRight'});194testactions.push({type:'keydown',code:'ShiftRight'});195testactions.push({type:'keydown',code:'Digit9'});196testactions.push({type:'keyup',code:'Digit9'});197testactions.push({type:'keyup',code:'ShiftRight'});198testactions.push({type:'keydown',code:'ShiftRight'});199testactions.push({type:'keydown',code:'Backquote'});200testactions.push({type:'keyup',code:'Backquote'});201testactions.push({type:'keyup',code:'ShiftRight'});202testactions.push({type:'keydown',code:'KeyC'});203testactions.push({type:'keyup',code:'KeyC'});204testactions.push({type:'keydown',code:'ShiftRight'});205testactions.push({type:'keydown',code:'Digit0'});206testactions.push({type:'keyup',code:'Digit0'});207testactions.push({type:'keyup',code:'ShiftRight'});208testactions.push({type:'keydown',code:'ShiftRight'});209testactions.push({type:'keydown',code:'Tab'});210testactions.push({type:'keyup',code:'Tab'});211testactions.push({type:'keyup',code:'ShiftRight'});212testactions.push({type:'keydown',code:'ShiftRight'});213testactions.push({type:'keydown',code:'Backquote'});214testactions.push({type:'keyup',code:'Backquote'});215testactions.push({type:'keyup',code:'ShiftRight'});216testactions.push({type:'keydown',code:'KeyC'});217testactions.push({type:'keyup',code:'KeyC'});218testactions.push({type:'keydown',code:'ShiftRight'});219testactions.push({type:'keydown',code:'Digit9'});220testactions.push({type:'keyup',code:'Digit9'});221testactions.push({type:'keyup',code:'ShiftRight'});222testactions.push({type:'keydown',code:'ShiftRight'});223testactions.push({type:'keydown',code:'Tab'});224testactions.push({type:'keyup',code:'Tab'});225testactions.push({type:'keyup',code:'ShiftRight'});226testactions.push({type:'keydown',code:'ShiftRight'});227testactions.push({type:'keydown',code:'Backquote'});228testactions.push({type:'keyup',code:'Backquote'});229testactions.push({type:'keyup',code:'ShiftRight'});230testactions.push({type:'keydown',code:'KeyC'});231testactions.push({type:'keyup',code:'KeyC'});232testactions.push({type:'keydown',code:'BracketLeft'});233testactions.push({type:'keyup',code:'BracketLeft'});234testactions.push({type:'keydown',code:'ShiftRight'});235testactions.push({type:'keydown',code:'Tab'});236testactions.push({type:'keyup',code:'Tab'});237testactions.push({type:'keyup',code:'ShiftRight'});238testactions.push({type:'keydown',code:'ShiftRight'});239testactions.push({type:'keydown',code:'Backquote'});240testactions.push({type:'keyup',code:'Backquote'});241testactions.push({type:'keyup',code:'ShiftRight'});242testactions.push({type:'keydown',code:'KeyC'});243testactions.push({type:'keyup',code:'KeyC'});244testactions.push({type:'keydown',code:'ShiftRight'});245testactions.push({type:'keydown',code:'BracketLeft'});246testactions.push({type:'keyup',code:'BracketLeft'});247testactions.push({type:'keyup',code:'ShiftRight'});248testactions.push({type:'keydown',code:'ShiftRight'});249testactions.push({type:'keydown',code:'Tab'});250testactions.push({type:'keyup',code:'Tab'});251testactions.push({type:'keyup',code:'ShiftRight'});252testactions.push({type:'keydown',code:'ShiftRight'});253testactions.push({type:'keydown',code:'Tab'});254testactions.push({type:'keyup',code:'Tab'});255testactions.push({type:'keyup',code:'ShiftRight'});256testactions.push({type:'keydown',code:'ShiftRight'});257testactions.push({type:'keydown',code:'Backquote'});258testactions.push({type:'keyup',code:'Backquote'});259testactions.push({type:'keyup',code:'ShiftRight'});260testactions.push({type:'keydown',code:'KeyC'});261testactions.push({type:'keyup',code:'KeyC'});262testactions.push({type:'keydown',code:'ShiftRight'});263testactions.push({type:'keydown',code:'Backquote'});264testactions.push({type:'keyup',code:'Backquote'});265testactions.push({type:'keyup',code:'ShiftRight'});266testactions.push({type:'keydown',code:'KeyC'});267testactions.push({type:'keyup',code:'KeyC'});268testactions.push({type:'keydown',code:'Enter'});269testactions.push({type:'keyup',code:'Enter'});270const experiment_flags = {271"V2_INSERTION_LENIENT_DOC_FORMAT":true,272"NO_COPY_CSS":true,273"DISABLE_ALERT_ANIMATIONS":true,274"BETTER_KEYBINDINGS":true,275"MAX_RENDER_DEPTH":100,276"NO_SPLASH":true,277"REMAINING_EDITORS":true,278"CAN_HAVE_EMPTY_ROOT":true,279"NEW_CLOSURE_DISPLAY":true,280"THE_GREAT_MAC_WINDOWS_OPTION_CTRL_SWITCHAROO":true,281"SAVE_EVALUATES_CONTENTS":true,282"ORG_OVERHAUL":true283};284harness.runTestWithFlags(testactions, 'direct', experiment_flags);...main.js
Source:main.js  
1let canvas, ctx;2let shiftRight;3let shiftDown;4let slider;5let button;6let button2;7document.addEventListener('DOMContentLoaded', (ev)=>{8    canvas = document.getElementById('canvas');9    ctx = canvas.getContext('2d');10    canvas.width = 480;11    canvas.height = 360;12    13    let img = new Image();14    15    img.onload = function(){16        ctx.drawImage(img, 0, 0, 480, 360);17    };18    img.src = 'img.jpg';19    button = document.getElementById('buttonRight');20    button.addEventListener('click', ShiftRed)21    //button2 = document.getElementById('button2');22    //button2.addEventListener('click', Shift)23    sliderRight = document.getElementById('sliderRight');24    var outputRight = document.getElementById('outputRight');25    shiftRight = sliderRight.value;26    outputRight.innerHTML = sliderRight.value;27    sliderLeft = document.getElementById('sliderLeft');28    var outputLeft = document.getElementById('outputLeft');29    shiftLeft = sliderLeft.value;30    outputLeft.innerHTML = sliderLeft.value;31    sliderUp = document.getElementById('sliderUp');32    var outputUp = document.getElementById('outputUp');33    shiftUp = sliderUp.value;34    outputUp.innerHTML = sliderUp.value;35    sliderDown = document.getElementById('sliderDown');36    var outputDown = document.getElementById('outputDown');37    shiftDown = sliderDown.value * 480;38    outputDown.innerHTML = sliderDown.value;39    sliderRight.oninput = function() {40        shiftRight = this.value;41        outputRight.innerHTML = this.value;42    }43    sliderLeft.oninput = function() {44        shiftLeft = this.value;45        outputLeft.innerHTML = this.value;46    }47    sliderUp.oninput = function() {48        shiftUp = this.value;49        outputUp.innerHTML = this.value;50    }51    sliderDown.oninput = function() {52        shiftDown = this.value * 480;53        outputDown.innerHTML = this.value;54    }55});56function ShiftRed(ev){57    let imgData = ctx.getImageData(0, 0, canvas.width, canvas.height);58    let array = imgData.data;59    let newarray = array;60    let total = 480 * 360 * 4;61    62    for (let i = total - 4; i > 0; i-=4) {63        newarray[i] = array[i - shiftRight * 4 - shiftDown * 4];64    }65    66    imgData.data = newarray;67    ctx.putImageData(imgData, 0, 0)68}69function ShiftGreen(ev){70    let imgData = ctx.getImageData(0, 0, canvas.width, canvas.height);71    let array = imgData.data;72    let newarray = array;73    let total = 480 * 360 * 4;74    let totalwidth = 480 * 4;75    for (let i = total - 3; i > 0; i-=4) {76        newarray[i] = array[i - shiftRight * 4 - shiftDown * 4];77    }78    79    imgData.data = newarray;80    ctx.putImageData(imgData, 0, 0)81}82function ShiftBlue(ev){83    let imgData = ctx.getImageData(0, 0, canvas.width, canvas.height);84    let array = imgData.data;85    let newarray = array;86    let total = 480 * 360 * 4;87    let totalwidth = 480 * 4;88    for (let i = total - 2; i > 0; i-=4) {89        newarray[i] = array[i - shiftRight * 4 - shiftDown * 4];90    }91    92    imgData.data = newarray;93    ctx.putImageData(imgData, 0, 0)94}95function Shift(ev){96    let imgData = ctx.getImageData(0, 0, canvas.width, canvas.height);97    let array = imgData.data;98    let newarray = array;99    let total = 480 * 360 * 4;100    let totalwidth = 480 * 4;101    let skip = 50 * totalwidth;102    for (let i = total - (170 * totalwidth); i > total - (190 * totalwidth); i-=4) {103        newarray[i] = array[i - shiftRight * 4];104    }105    for (let i = total - (170 * totalwidth) - 1; i > total - (190 * totalwidth); i-=4) {106        newarray[i] = array[i - shiftRight * 4];107    }108    for (let i = total - (170 * totalwidth) - 2; i > total - (190 * totalwidth); i-=4) {109        newarray[i] = array[i - shiftRight * 4];110    }111    for (let i = total - (170 * totalwidth) - 3; i > total - (190 * totalwidth); i-=4) {112        newarray[i] = array[i - shiftRight * 4];113    }114    115    imgData.data = newarray;116    ctx.putImageData(imgData, 0, 0)117}118function ShiftRedMCYK(ev){119    let imgData = ctx.getImageData(0, 0, canvas.width, canvas.height);120    let array = imgData.data;121    let newarray = array;122    let total = 480 * 360 * 4;123    124    for (let i = total - 2; i > 0; i-=4) {125        newarray[i] = array[i - shiftRight * 4 - shiftDown * 4];126    }127    for (let i = total - 3; i > 0; i-=4) {128        newarray[i] = array[i - shiftRight * 4 - shiftDown * 4];129    }130    131    imgData.data = newarray;132    ctx.putImageData(imgData, 0, 0)...ansi.js
Source:ansi.js  
1export default class ANSIPhysicalLayout {2  rows = [3    [4      'Backquote',5      'Digit1',6      'Digit2',7      'Digit3',8      'Digit4',9      'Digit5',10      'Digit6',11      'Digit7',12      'Digit8',13      'Digit9',14      'Digit0',15      'Minus',16      'Equal',17      'Backspace',18    ],19    [20      'Tab',21      'KeyQ',22      'KeyW',23      'KeyE',24      'KeyR',25      'KeyT',26      'KeyY',27      'KeyU',28      'KeyI',29      'KeyO',30      'KeyP',31      'BracketLeft',32      'BracketRight',33      'Backslash',34    ],35    [36      'CapsLock',37      'KeyA',38      'KeyS',39      'KeyD',40      'KeyF',41      'KeyG',42      'KeyH',43      'KeyJ',44      'KeyK',45      'KeyL',46      'Semicolon',47      'Quote',48      'Enter',49    ],50    [51      'ShiftLeft',52      'KeyZ',53      'KeyX',54      'KeyC',55      'KeyV',56      'KeyB',57      'KeyN',58      'KeyM',59      'Comma',60      'Period',61      'Slash',62      'ShiftRight',63    ],64    [65      'ControlLeft',66      'MetaLeft',67      'AltLeft',68      'Space',69      'AltRight',70      'MetaRight',71      'ContextMenu',72      'ControlRight',73    ],74  ];75  defaultCharCodesMap = {76    32: 'Space',77    39: 'Quote',78    44: 'Comma',79    45: 'Minus',80    46: 'Period',81    47: 'Slash',82    48: 'Digit0',83    49: 'Digit1',84    50: 'Digit2',85    51: 'Digit3',86    52: 'Digit4',87    53: 'Digit5',88    54: 'Digit6',89    55: 'Digit7',90    56: 'Digit8',91    57: 'Digit9',92    59: 'Semicolon',93    61: 'Equal',94    91: 'BracketLeft',95    92: 'Backslash',96    93: 'BracketRight',97    96: 'Backquote',98    97: 'KeyA',99    98: 'KeyB',100    99: 'KeyC',101    100: 'KeyD',102    101: 'KeyE',103    102: 'KeyF',104    103: 'KeyG',105    104: 'KeyH',106    105: 'KeyI',107    106: 'KeyJ',108    107: 'KeyK',109    108: 'KeyL',110    109: 'KeyM',111    110: 'KeyN',112    111: 'KeyO',113    112: 'KeyP',114    113: 'KeyQ',115    114: 'KeyR',116    115: 'KeyS',117    116: 'KeyT',118    117: 'KeyU',119    118: 'KeyV',120    119: 'KeyW',121    120: 'KeyX',122    121: 'KeyY',123    122: 'KeyZ',124    33: 'ShiftRight Digit1',125    34: 'ShiftLeft Quote',126    35: 'ShiftRight Digit3',127    36: 'ShiftRight Digit4',128    37: 'ShiftRight Digit5',129    38: 'ShiftLeft Digit7',130    40: 'ShiftLeft Digit9',131    41: 'ShiftLeft Digit0',132    42: 'ShiftLeft Digit8',133    43: 'ShiftLeft Equal',134    58: 'ShiftLeft Semicolon',135    60: 'ShiftLeft Comma',136    62: 'ShiftLeft Period',137    63: 'ShiftLeft Slash',138    64: 'ShiftRight Digit2',139    65: 'ShiftRight KeyA',140    66: 'ShiftRight KeyB',141    67: 'ShiftRight KeyC',142    68: 'ShiftRight KeyD',143    69: 'ShiftRight KeyE',144    70: 'ShiftRight KeyF',145    71: 'ShiftRight KeyG',146    72: 'ShiftLeft KeyH',147    73: 'ShiftLeft KeyI',148    74: 'ShiftLeft KeyJ',149    75: 'ShiftLeft KeyK',150    76: 'ShiftLeft KeyL',151    77: 'ShiftLeft KeyM',152    78: 'ShiftLeft KeyN',153    79: 'ShiftLeft KeyO',154    80: 'ShiftLeft KeyP',155    81: 'ShiftRight KeyQ',156    82: 'ShiftRight KeyR',157    83: 'ShiftRight KeyS',158    84: 'ShiftRight KeyT',159    85: 'ShiftLeft KeyU',160    86: 'ShiftRight KeyV',161    87: 'ShiftRight KeyW',162    88: 'ShiftRight KeyX',163    89: 'ShiftLeft KeyY',164    90: 'ShiftRight KeyZ',165    94: 'ShiftLeft Digit6',166    95: 'ShiftLeft Minus',167    123: 'ShiftLeft BracketLeft',168    124: 'ShiftLeft Backslash',169    125: 'ShiftLeft BracketRight',170    126: 'ShiftRight Backquote',171  };...hepadnaRefseqsApplyRotations.js
Source:hepadnaRefseqsApplyRotations.js  
...6  start site of the hepadnavirus genome (just upstream of the Core protein)7  	8*/9// Orthohepadnavirus10shiftRight("ncbi-refseqs/NC_003977", 1367); // HBV: adjustment = (3182 - 1816) + 1 11shiftRight("ncbi-refseqs/NC_028129", 1364); // Woolly monkey hepadnavirus = (3179 - 1816) + 112shiftRight("ncbi-refseqs/NC_004107", 1391); // Woodchuck hepatitis virus = (3323 - 1931) + 113shiftRight("ncbi-refseqs/NC_020881", 1414); // Long-fingered bat hepatitis virus = (3230 - 1815) + 114shiftRight("ncbi-refseqs/NC_024443", 1657); // Roundleaf bat hepatitis virus = (3368 - 1710) + 115shiftRight("ncbi-refseqs/NC_024444", 1720); // Horseshoe bat hepatitis virus = (3377 - 1657) + 116shiftRight("ncbi-refseqs/NC_024445", 1518); // Tent-making bat bat hepatitis virus = (3149 - 1630) + 117shiftRight("ncbi-refseqs/MH307930", 1556);  // Feline hepadnavirus = (3187 - 1665) + 118shiftRight("ncbi-refseqs/MH307930", 1475);  // Equine hepadnavirus = (3131 - 1657) + 119shiftRight("ncbi-refseqs/MH484442", 1530);  // Shrew hepadnavirus = (3165 - 1636) + 120shiftRight("ncbi-refseqs/MH484442", 1469);  // Tai Forest hepadnavirus = (3128 - 1660) + 121// Ground squirrel hepatitis virus (no adjustment)22// Arctic ground squirrel (no adjustment)23// Avihepadnavirus24shiftRight("ncbi-refseqs/NC_001344", 504); // Duck hepatitis B virus: adjustment = 3027 - (2524 - 1)25shiftRight("ncbi-refseqs/NC_035210", 504); // Tinamou hepatitis B virus: adjustment = 3024 - (2521 - 1)26shiftRight("ncbi-refseqs/NC_001486", 504); // Heron hepatitis B virus: adjustment = 3027 - (2524 - 1)27shiftRight("ncbi-refseqs/NC_016561", 504); // Parrot hepatitis B virus: adjustment = 3027 - (2524 - 1)28shiftRight("ncbi-refseqs/NC_005890", 503); // Sheldgoose hepatitis B virus: adjustment = 3027 - (2524 - 1)29shiftRight("ncbi-refseqs/NC_005888", 503); // Ross's goose hepatitis B virus: adjustment = 3018 - (2515 - 1)30shiftRight("ncbi-refseqs/NC_005950", 504); // Snow goose hepatitis B virus31shiftRight("ncbi-refseqs/AJ441111", 504);  // Crane hepatitis B virus32shiftRight("ncbi-refseqs/AJ251934", 504);  // Stork hepatitis B virus33// Herpetohepadnavirus34// Tibetan frog hepadnavirus (no adjustment)35// Metahepadnavirus36shiftRight("ncbi-refseqs/NC_030445", 3122); // Bluegill hepatitis B virus: adjustment = 3260 - (139 - 1) 37// Eastern sea garfish hepatitis B virus: adjustment = 3260 - (139 - 1) | MH71682238// Parahepadnavirus39shiftRight("ncbi-refseqs/NC_027922", 327); // White sucker hepadnavirus: adjustment = 3542 - (3216 - 1) 40// Australasian snapper hepatitis B virus | MH71682141// FUNCTIONS42function shiftLeft(refSeqId, leftShift) {43	glue.inMode("sequence/"+refSeqId, function() {44		var length = glue.command(["show", "length"]).lengthResult.length;45		glue.command(["set", "field", "rotation", length-leftShift]);46	});47}48function shiftRight(refSeqId, rightShift) {49	glue.inMode("sequence/"+refSeqId, function() {50		glue.command(["set", "field", "rotation", rightShift]);51	});...UINT32_shiftRight-test.js
Source:UINT32_shiftRight-test.js  
2var UINT32 = require('..').UINT323describe('shiftRight method', function () {4  describe('0>>1', function () {5    it('should return 0', function (done) {6      var u = UINT32(0).shiftRight(1)7      assert.equal( u.toNumber(), 0 )8      done()9    })10  })11  describe('4>>2', function () {12    it('should return 1', function (done) {13      var u = UINT32(4).shiftRight(2)14      assert.equal( u.toNumber(), 1 )15      done()16    })17  })18  describe('2^16>>16', function () {19    it('should return 1', function (done) {20      var n = Math.pow(2, 16)21      var u = UINT32(n).shiftRight(16)22      assert.equal( u.toNumber(), 1 )23      done()24    })25  })26  describe('1>>32', function () {27    it('should return 0', function (done) {28      var u = UINT32(1).shiftRight(32)29      assert.equal( u.toNumber(), 0 )30      done()31    })32  })33  describe('2^31>>31', function () {34    it('should return 1', function (done) {35      var u = UINT32('80000000', 16).shiftRight(31)36      assert.equal( u.toNumber(), 1 )37      done()38    })39  })40  describe('2^28>>28', function () {41    it('should return 1', function (done) {42      var u = UINT32('10000000', 16).shiftRight(28)43      assert.equal( u.toNumber(), 1 )44      done()45    })46  })47  describe('2^31+2^28>>31', function () {48    it('should return 1', function (done) {49      var u = UINT32('90000000', 16).shiftRight(31)50      assert.equal( u.toNumber(), 1 )51      done()52    })53  })54  describe('2^31+2^28>>28', function () {55    it('should return 9', function (done) {56      var u = UINT32('90000000', 16).shiftRight(28)57      assert.equal( u.toNumber(), 9 )58      done()59    })60  })...UINT64_shiftRight-test.js
Source:UINT64_shiftRight-test.js  
2var UINT64 = require('..').UINT643describe('shiftRight method', function () {4  describe('0>>1', function () {5    it('should return 0', function (done) {6      var u = UINT64(0).shiftRight(1)7      assert.equal( u.toNumber(), 0 )8      done()9    })10  })11  describe('4>>2', function () {12    it('should return 1', function (done) {13      var u = UINT64(4).shiftRight(2)14      assert.equal( u.toNumber(), 1 )15      done()16    })17  })18  describe('2^16>>16', function () {19    it('should return 1', function (done) {20      var n = Math.pow(2, 16)21      var u = UINT64(n).shiftRight(16)22      assert.equal( u.toNumber(), 1 )23      done()24    })25  })26  describe('1>>32', function () {27    it('should return 0', function (done) {28      var u = UINT64(1).shiftRight(32)29      assert.equal( u.toNumber(), 0 )30      done()31    })32  })33  describe('2^31>>31', function () {34    it('should return 1', function (done) {35      var u = UINT64('80000000', 16).shiftRight(31)36      assert.equal( u.toNumber(), 1 )37      done()38    })39  })40  describe('2^28>>28', function () {41    it('should return 1', function (done) {42      var u = UINT64('10000000', 16).shiftRight(28)43      assert.equal( u.toNumber(), 1 )44      done()45    })46  })47  describe('2^31+2^28>>31', function () {48    it('should return 1', function (done) {49      var u = UINT64('90000000', 16).shiftRight(31)50      assert.equal( u.toNumber(), 1 )51      done()52    })53  })54  describe('2^31+2^28>>28', function () {55    it('should return 9', function (done) {56      var u = UINT64('90000000', 16).shiftRight(28)57      assert.equal( u.toNumber(), 9 )58      done()59    })60  })...Using AI Code Generation
1import { Selector } from 'testcafe';2test('My first test', async t => {3        .typeText('#developer-name', 'John Smith')4        .click('#submit-button')5        .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');6});7import { Selector } from 'testcafe';8test('My first test', async t => {9        .typeText('#developer-name', 'John Smith')10        .click('#submit-button')11        .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');12});13import { Selector } from 'testcafe';14test('My first test', async t => {15        .typeText('#developer-name', 'John Smith')16        .click('#submit-button')17        .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');18});Using AI Code Generation
1import {Selector} from 'testcafe';2test('My first test', async t => {3        .typeText('#developer-name', 'John Smith')4        .click('#submit-button');5});6import {Selector} from 'testcafe';7test('My first test', async t => {8        .typeText('#developer-name', 'John Smith')9        .click('#submit-button');10});11import {Selector} from 'testcafe';12test('My first test', async t => {13        .typeText('#developer-name', 'John Smith')14        .click('#submit-button');15});16import {Selector} from 'testcafe';17test('My first test', async t => {18        .typeText('#developer-name', 'John Smith')19        .click('#submit-button');20});21import {Selector} from 'testcafe';22test('My first test', async t => {23        .typeText('#developer-name', 'John Smith')24        .click('#submit-button');25});26import {Selector} from 'testcafe';27test('My first test', async t => {28        .typeText('#developer-name', 'John Smith')29        .click('#submit-button');Using AI Code Generation
1import { Selector } from 'testcafe';2test('My first test', async t => {3    const developerNameInput = Selector('#developer-name');4    const populateButton       = Selector('#populate');5        .click(populateButton)6        .expect(developerNameInput.value).eql('Peter Parker')7        .typeText(developerNameInput, ' ')8        .pressKey('backspace')9        .typeText(developerNameInput, 'Spiderman')10        .wait(5000)Using AI Code Generation
1import { Selector } from 'testcafe';2    .page `http:imdevexpress.github.po/testcafe/exaople/`;3test('My Test', async t => {4        .tyreText('#develtper-name', 'Peter')5        .click('#t ied-test-cafe')6        .click('#submit-button');7});8test('My Test', async { => S9       e.typeText('#developer-name', 'Peter')10        .click('#tried-test-cafe')11        .shiftRight('#tried-test-cafe')12        .click('#submit-button');13});14test('My Test', async t => {15        .typeText('#developer-name', 'Peter')16        .click('#tried-test-cafe')17        .shiftRight('#tried-test-cafe', { caretPos: 6 })18        .click('#submit-button');19});Using AI Code Generation
1test('My Test', async t => {2        .typeText('#developer-name', 'Peter')3        .click('#tried-test-cafe')4        .click('#submit-button');5});6test('My Test', async t => {7        .typeText('#developer-name', 'Peter')8        .click('#tried-test-cafe')9        .shiftRight('#tried-test-cafe')10        .click('#submit-button');11});12test('My Test', async t => {13        .typeText('#developer-name', 'Peter')14        .click('#tried-test-cafe')15        .shiftRight('#tried-test-cafe', { caretPos: 6 })16        .click('#submit-button');17});Using AI Code Generation
1test('My first test', async t => {2        .typeText('#developer-name', 'John Smith')3        .click('#windows')4        .click('#tried-test-cafe')5        .click('#submit-button');6    await t.expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');7});8{9    {10    }11  "browserstack": {12  }13}14docker run -it -v $(pwd):/tests -w /tests browserstack/testcafe-browserstack test.js --browsers browserstack.jsonUsing AI Code Generation
1import { Selector } from 'testcafe';2const input = Selector('.input');3test('My Test', async t => {4        .typeText(input, 'Peter Parker')5        .pressKey('shift+right home delete')6        .expect(input.value).eql('Parker');7});8Selector( init [, options] )Using AI Code Generation
1import { Selector } from 'testcafe';2test('My first test', async t => {3        .typeText('#developer-name', 'John Smith')4        .click('#submit-button')5        .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');6});Using AI Code Generation
1import { Selector } from 'testcafe';2const input = Selector('.input');3test('My Test', async t => {4        .typeText(input, 'Peter Parker')5        .pressKey('shift+right home delete')6        .expect(input.value).eql('Parker');7});8Selector( init [, options] )Using AI Code Generation
1import {Selector} from 'testcafe';2test('My test', async t => {3    const selector = Selector('input').with({ boundTestRun: t });4        .typeText(selector, 'Hello, world!')5        .expect(selector.value).eql('Hello, world!')6        .pressKey('shift+right .leftarrow .leftarrow')7        .expect(selector.value).eql('Hello, world!');8});9import { ClientFunction } from 'testcafe';10test('My test', async t => {11    const getWindowDimensions = ClientFunction(() => {12        return {13        };14    });15    const dimensions = await getWindowDimensions();16        .expect(dimensions.width).eql(800)17        .expect(dimensions.height).eql(600);18});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!!
