Best JavaScript code snippet using wpt
parse-prog.ts
Source:parse-prog.ts
1/******************************************************************************2 * SELL - SIMPLE E-LEARNING LANGUAGE *3 * *4 * Copyright (c) 2019-2021 TH Köln *5 * Author: Andreas Schwenk, contact@compiler-construction.com *6 * *7 * Partly funded by: Digitale Hochschule NRW *8 * https://www.dh.nrw/kooperationen/hm4mint.nrw-31 *9 * *10 * GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 *11 * *12 * This library is licensed as described in LICENSE, which you should have *13 * received as part of this distribution. *14 * *15 * This software is distributed on "AS IS" basis, WITHOUT WARRENTY OF ANY *16 * KIND, either impressed or implied. *17 ******************************************************************************/18// prog := programming19import { symtype, SellSymbol } from './symbol';20import { SellQuiz } from './quiz';21export class ParseProg {22 p: SellQuiz;23 constructor(parent: SellQuiz) {24 this.p = parent;25 }26 // prog =27 // ("JavaBlock"|"JavaMethod"|"Python") ID "\n"28 // "§CODE2_START"29 // (prog_given|prog_assert)30 // "§CODE2_END";31 parseProg(): void {32 let type = '';33 if (this.p.is('JavaBlock')) type = 'JavaBlock';34 else if (this.p.is('JavaMethod')) type = 'JavaMethod';35 else if (this.p.is('Python')) type = 'Python';36 else this.p.err('unknown programming type ' + this.p.tk);37 this.p.next();38 this.p.ident();39 const sym_id = this.p.id;40 this.p.terminal('§EOL');41 this.p.terminal('§CODE2_START');42 let code_given = '';43 const assert_list = [];44 while (this.p.is('given') || this.p.is('assert')) {45 if (this.p.is('given')) code_given += this.parseProgGiven();46 else assert_list.push(this.parseProgAssert());47 }48 this.p.terminal('§CODE2_END');49 this.p.q.symbols[sym_id] = new SellSymbol(symtype.T_PROGRAMMING, {50 type: type,51 given: code_given,52 asserts: assert_list,53 });54 }55 // prog_given =56 // "given" "'" ANY "'" "\n";57 parseProgGiven(): string {58 this.p.terminal('given');59 this.p.terminal("'");60 this.p.parseWhitespaces = true;61 let given_str = '';62 while (!this.p.is("'") && !this.p.is('§END')) {63 given_str += this.p.tk;64 this.p.next();65 }66 this.p.terminal("'");67 this.p.parseWhitespaces = false;68 this.p.terminal('§EOL');69 return given_str + '\n';70 }71 // prog_assert =72 // "assert" "'" ANY "'" "\n";73 parseProgAssert(): string {74 this.p.terminal('assert');75 this.p.terminal("'");76 this.p.parseWhitespaces = true;77 let assert_str = '';78 while (!this.p.is("'") && !this.p.is('§END')) {79 assert_str += this.p.tk;80 this.p.next();81 }82 this.p.terminal("'");83 this.p.parseWhitespaces = false;84 this.p.terminal('§EOL');85 return assert_str;86 }...
commons.js
Source:commons.js
1const assert = require('assert');2const assert_dict = (a, b) => {3 try { 4 assert.deepStrictEqual(a, b);5 return true;6 } catch (error) {7 return false8 }9}10const assert_list = (a, b) => {11 try { 12 assert.deepStrictEqual(a, b);13 return true;14 } catch (error) {15 return false16 }17}18const assert_float = (a, b) => {19 return (20 typeof a === "number" && typeof b === "number" && !Number.isInteger(a) && !Number.isInteger(b) && a === b21 )22}23exports.assert_float = assert_float24exports.assert_list = assert_list...
Using AI Code Generation
1var wpt = require('webpagetest');2var assert = require('assert');3var wpt = new WebPageTest('www.webpagetest.org');4 if (err) return console.error(err);5 wpt.getTestResults(data.data.testId, function(err, data) {6 if (err) return console.error(err);7 var testResults = data.data;8 var testId = data.data.testId;9 var url = data.data.url;10 var location = data.data.location;11 var locationLabel = data.data.locationLabel;12 var from = data.data.from;13 var connectivity = data.data.connectivity;14 var bwDown = data.data.bwDown;15 var bwUp = data.data.bwUp;16 var latency = data.data.latency;17 var plr = data.data.plr;18 var completed = data.data.completed;19 var tester = data.data.tester;20 var testUrl = data.data.testUrl;21 var fvonly = data.data.fvonly;22 var runs = data.data.runs;23 var successfulFVRuns = data.data.successfulFVRuns;24 var successfulRVRuns = data.data.successfulRVRuns;25 var successfulRuns = data.data.successfulRuns;26 var average = data.data.average;27 var median = data.data.median;28 var standardDeviation = data.data.standardDeviation;29 var medianRun = data.data.medianRun;30 var firstView = data.data.firstView;31 var repeatView = data.data.repeatView;32 var runs = data.data.runs;33 var run = data.data.runs[0];34 var runNumber = data.data.runs[0].run;35 var firstView = data.data.runs[0].firstView;36 var repeatView = data.data.runs[0].repeatView;37 var firstView = data.data.runs[0].firstView;38 var loadTime = data.data.runs[0].firstView.loadTime;39 var TTFB = data.data.runs[0].firstView.TTFB;40 var bytesIn = data.data.runs[0].firstView.bytesIn;41 var bytesOut = data.data.runs[0].firstView.bytesOut;
Using AI Code Generation
1var wpt = require('webpagetest');2var assert = require('assert');3var test = require('wpt/assert_list');4var wpt = new WebPageTest('www.webpagetest.org');5 if (err) return console.error(err);6 var testId = data.data.testId;7 wpt.getTestResults(testId, function(err, data) {8 if (err) return console.error(err);9 test.assert_list(10 );11 });12});13var wpt = require('webpagetest');14var assert = require('assert');15var test = require('wpt/assert_list');16var wpt = new WebPageTest('www.webpagetest.org');17 if (err) return console.error(err);18 var testId = data.data.testId;19 wpt.getTestResults(testId, function(err, data) {20 if (err) return console.error(err);21 test.assert_list(22 );23 });24});25var wpt = require('webpagetest');26var assert = require('assert');27var test = require('wpt/assert_list');28var wpt = new WebPageTest('www.webpagetest.org');29 if (err) return console.error(err);30 var testId = data.data.testId;31 wpt.getTestResults(testId, function(err, data) {32 if (err) return console.error(err);33 test.assert_list(34 );35 });36});
Using AI Code Generation
1var assert_list = require('./assert_list.js');2var assert = require('assert');3describe('assert_list', function() {4 describe('#assert_list()', function() {5 it('should return true if the list is empty', function() {6 assert.equal(assert_list.assert_list([]), true);7 });8 it('should return true if the list is not empty', function() {9 assert.equal(assert_list.assert_list([1,2,3]), true);10 });11 });12});13var assert = require('assert');14exports.assert_list = function(list) {15 assert(Array.isArray(list));16 return true;17}
Using AI Code Generation
1var assert_list = require('./assert.js').assert_list;2assert_list(1, 1, "1 is equal to 1");3assert_list(1, 2, "1 is not equal to 2");4assert_list(1, 1, "1 is equal to 1");5assert_list(1, 2, "1 is not equal to 2");6assert_list(1, 1, "1 is equal to 1");7assert_list(1, 2, "1 is not equal to 2");8assert_list(1, 1, "1 is equal to 1");9assert_list(1, 2, "1 is not equal to 2");10assert_list(1, 1, "1 is equal to 1");11assert_list(1, 2, "1 is not equal to 2");12assert_list(1, 1, "1 is equal to 1");13assert_list(1, 2, "1 is not equal to 2");14assert_list(1, 1, "1 is equal to 1");15assert_list(1, 2, "1 is not equal to 2");16assert_list(1, 1, "1 is equal to 1");17assert_list(1, 2, "1 is not equal to 2");18assert_list(1, 1, "1 is equal to 1");19assert_list(1, 2, "1 is not equal to 2");20assert_list(1, 1, "1 is equal to 1");21assert_list(1, 2, "1 is not equal to 2");22assert_list(1, 1, "1 is equal to 1");23assert_list(1, 2, "1 is not equal to 2");24assert_list(1, 1, "1 is equal to 1");25assert_list(1, 2, "1 is not equal to 2");26assert_list(1, 1, "1 is equal to 1");27assert_list(1, 2, "1 is
Using AI Code Generation
1var assert_list = require('./assert_list.js');2assert_list('test', ['test1', 'test2'], function(err, result) {3 if (err) {4 console.log(err);5 } else {6 console.log(result);7 }8});9var assert = require('assert');10module.exports = function(assert_value, list, callback) {11 try {12 assert.ok(list.indexOf(assert_value) > -1);13 callback(null, true);14 } catch (err) {15 callback(err, null);16 }17}
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!!