How to use parseModes method in Testcafe

Best JavaScript code snippet using testcafe

uber-document-functions.js

Source:uber-document-functions.js Github

copy

Full Screen

1/**2 * 3 * @param {FileList} uberDocuments Uber売り上げPDF配列4 * @returns {Array<UberPaymentData>} Uber売り上げデータ配列5 */6async function uberDocumentsToDatas(uberDocuments) {7 const uberPaymentDatas = new Array();8 // メモリ使用量を考慮し、同期しながらPDFを1つずつ変換する9 for(let uberDocument of uberDocuments) {10 const uberPaymentData = await uberDocumentToData(uberDocument);11 // 日付以外の売り上げなどの情報が存在すれば追加12 if (!uberPaymentData.isZero()) {13 uberPaymentDatas.push(uberPaymentData);14 }15 }16 return uberPaymentDatas;17}18/**19 * Uber売上PDFの変換20 * 21 * @param {File} uberDocument Uber売り上げのPDFファイル22 * @returns Uber売り上げデータ23 */24 async function uberDocumentToData(uberDocument) {25 // PDFファイル読み込み26 // (fileReader.onloadがPromiseじゃないので、Promiseにする)27 const fileReader = new FileReader();28 const fileReadPromise = BrowserUtils.generatePromiseWithFileReader(fileReader);29 fileReader.readAsArrayBuffer(uberDocument);30 const arrayBuffer = await fileReadPromise;31 // PDFからArray<TextItem | TextMarkedContent>を取得32 // 参考33 // https://github.com/mozilla/pdf.js/blob/master/src/display/api.js#L68934 // https://github.com/mozilla/pdf.js/blob/master/src/display/api.js#L108235 // https://stackoverflow.com/a/6217341636 const pdfDocumentProxy = await pdfjsLib.getDocument(new Uint8Array(arrayBuffer)).promise;37 // 対象のページを、Array<TextItem | TextMarkedContent>に変換38 const textItems = new Array();39 for (let i = UberDocumentConstants.UBER_SALE_FIRST_PAGE_INDEX; i <= pdfDocumentProxy.numPages && i <= UberDocumentConstants.UBER_SALE_PAGE_NUM; ++i) {40 const page = await pdfDocumentProxy.getPage(i);41 // TextContent https://github.com/mozilla/pdf.js/blob/master/src/display/api.js#L108142 const textContent = await page.getTextContent();43 ArrayUtils.pushArray(textItems, textContent.items);44 } 45 46 // さらにUberPaymentDataに変換47 return textItemsToData(textItems);48}49/**50 * PDFのテキスト情報からデータ用のクラスに変換51 * @param {Array<TextItem | TextMarkedContent>} textItems 52 * @returns Uber売り上げデータ53 */54function textItemsToData(textItems) {55 const uberPaymentData = new UberPaymentData();56 // 前回の解析モード(キャンセルのときに元に戻すため)57 let previousParseMode;58 // 利用する解析モード59 const parseModes = [60 61 // 週の始まりの日付を探して保存62 new ParseMode(UberDocumentConstants.UBER_START_DATE_PATTERN, (result, index, source) => {63 uberPaymentData.startDate = SimpleDate.ofString(result[UberDocumentConstants.REGEXP_EXEC_PART_INDEX], UberDocumentConstants.UBER_DATE_SEPARATOR);64 }),65 // 週の終わりの日付を探して保存66 new ParseMode(UberDocumentConstants.UBER_END_DATE_PATTERN, (result, index, source) => {67 uberPaymentData.endDate = SimpleDate.ofString(result[UberDocumentConstants.REGEXP_EXEC_PART_INDEX], UberDocumentConstants.UBER_DATE_SEPARATOR);68 }),69 // 売り上げのラベルを探し、次の数値を売り上げとみなす70 new ParseMode(UberDocumentConstants.UBER_SALE_LABEL_PATTERN, (result, index, source) => {71 parseModes.unshift(new IntegerParseMode(72 num => uberPaymentData.sale = num,73 true,74 // 売り上げだけは、「売り上げの明細」が先に読み込まれてしまう場合があるため元に戻す75 UberDocumentConstants.UBER_SALE_REVERT_PATTERN76 ));77 }),78 // サービス料(支払手数料)のラベルを探し、次の数値を支払手数料とみなす79 new ParseMode(UberDocumentConstants.UBER_FEE_LABEL_PATTERN, (result, index, source) => {80 parseModes.unshift(new IntegerParseMode(num => uberPaymentData.fee = num, true));81 }),82 // 銀行口座への振り込みのラベルを探す83 new ParseMode(UberDocumentConstants.UBER_DEPOSIT_LABEL_PATTERN, (result, index, source) => {84 // 振込年は週の始まりの日付(例:2021/05/03)から取得85 uberPaymentData.depositDate = new SimpleDate();86 if (uberPaymentData.startDate) {87 uberPaymentData.depositDate.year = uberPaymentData.startDate.year;88 }89 // ない場合はないはずだが、もしそういう状況が発生した場合は、一応前年を設定90 else {91 uberPaymentData.depositDate.year = UberDocumentConstants.TODAY.getFullYear();92 }93 // ラベルより前に振込日付が書いてあるため、前を探して設定94 // 例:5月3日(月) 4:01 に銀行口座に振り込まれました95 // 汚いが、他の手段が思いつかない96 // ( の位置まで戻る97 do {98 --index;99 } while(source[index].str != "(");100 // 次の数値が日101 let regExpExecArray;102 do {103 --index;104 regExpExecArray = UberDocumentConstants.UBER_INTEGER_PATTERN.exec(source[index].str);105 } while(regExpExecArray == null);106 uberPaymentData.depositDate.day = regExpExecArray[UberDocumentConstants.REGEXP_EXEC_RESULT_INDEX];107 // 次の数値が月108 do {109 --index;110 regExpExecArray = UberDocumentConstants.UBER_INTEGER_PATTERN.exec(source[index].str);111 } while(regExpExecArray == null);112 uberPaymentData.depositDate.month = regExpExecArray[UberDocumentConstants.REGEXP_EXEC_RESULT_INDEX];113 // 次の数値を振り込まれた金額とみなす114 parseModes.unshift(new IntegerParseMode(num => uberPaymentData.deposit = num, true));115 }),116 // 受け取った現金のラベルを探し、次の数値を振り込まれた金額とみなす117 new ParseMode(UberDocumentConstants.UBER_CASH_LABEL_PATTERN, (result, index, source) => {118 parseModes.unshift(new IntegerParseMode(num => uberPaymentData.cash = num, true));119 }),120 // 返金と経費のラベルを探し、次の数値を振り込まれた金額とみなす121 new ParseMode(UberDocumentConstants.UBER_REPAYMENT_LABEL_PATTERN, (result, index, source) => {122 parseModes.unshift(primalParseMode = new IntegerParseMode(num => uberPaymentData.repayment = num, true));123 }),124 ];125 // テキストを1つずつ解析126 for(let i = 0; i < textItems.length; ++i) {127 const textItem = textItems[i];128 if (!textItem || !textItem.str) {129 continue;130 }131 // 他の解析モード実行、終了したらそのモードを消す132 for (const parseMode of parseModes) {133 if (parseMode.actionIfExecutable(textItem.str, i, textItems)) {134 ArrayUtils.delete(parseModes, parseMode);135 previousParseMode = parseMode;136 // 取得する情報がなくなったら返す137 if (parseModes.length <= 0 && !primalParseMode) {138 return uberPaymentData;139 }140 break;141 }142 // 元に戻す条件に一致した場合は元に戻す143 if (parseMode.revertPattern && parseMode.revertPattern.test(textItem.str) && previousParseMode) {144 ArrayUtils.delete(parseModes, parseMode);145 parseModes.unshift(previousParseMode);146 previousParseMode = null;147 break;148 }149 150 // 優先解析モードの場合は次のテキストへ151 if (parseMode.primalFlag) {152 break;153 }154 }155 }156 return uberPaymentData;...

Full Screen

Full Screen

13.js

Source:13.js Github

copy

Full Screen

...80 op = String(op).padStart(2, '0');81 // Input82 if (effectiveOp(op) === '03') {83 let targetIdx = state.mem[state.pointer + 1];84 if (parseModes(op)[0] == '2') {85 targetIdx += state.rbase;86 }87 const value = await input();88 return {89 ...state,90 pointer: state.pointer + 2,91 mem: set(state, targetIdx, value).mem,92 };93 } else if (effectiveOp(op) === '01') { // Sum94 const args = readArgs(state, 2, parseModes(op));95 let targetIdx = state.mem[state.pointer + 3];96 if(parseModes(op)[2] == '2') {97 targetIdx += state.rbase;98 }99 return {100 ...state,101 pointer: state.pointer + 4,102 mem: set(state, targetIdx, R.sum(args)).mem,103 };104 } else if (effectiveOp(op) === '02') { // Product105 const args = readArgs(state, 2, parseModes(op));106 let targetIdx = state.mem[state.pointer + 3];107 if(parseModes(op)[2] == '2') {108 targetIdx += state.rbase;109 }110 return {111 ...state,112 pointer: state.pointer + 4,113 mem: set(state, targetIdx, R.product(args)).mem,114 };115 } else if (effectiveOp(op) === '99') { // Exit116 console.log("Finished");117 return {118 ...state,119 pointer: -1120 };121 } else if (effectiveOp(op) === '04') { // Output122 const args = readArgs(state, 1, parseModes(op));123 output(args[0]);124 return {125 ...state,126 pointer: state.pointer + 2,127 };128 } else if (effectiveOp(op) === '05') { // Jump If True129 const args = readArgs(state, 2, parseModes(op));130 if (args[0] !== 0) {131 return {132 ...state,133 pointer: args[1]134 };135 } else {136 return {137 ...state,138 pointer: state.pointer + 3,139 };140 }141 } else if (effectiveOp(op) === '06') { // Jump if False142 const args = readArgs(state, 2, parseModes(op));143 if (args[0] === 0) {144 return {145 ...state,146 pointer: args[1],147 };148 } else {149 return {150 ...state,151 pointer: state.pointer + 3,152 };153 }154 } else if (effectiveOp(op) === '07') { // less than155 const args = readArgs(state, 2, parseModes(op));156 let targetIdx = state.mem[state.pointer + 3];157 if(parseModes(op)[2] == '2') {158 targetIdx += state.rbase;159 }160 if (args[0] < args[1]) {161 return {162 ...state,163 pointer: state.pointer + 4,164 mem: set(state, targetIdx, 1).mem,165 };166 } else {167 return {168 ...state,169 pointer: state.pointer + 4,170 mem: set(state, targetIdx, 0).mem,171 };172 }173 } else if (effectiveOp(op) === '08') { // Equals174 const args = readArgs(state, 2, parseModes(op));175 let targetIdx = state.mem[state.pointer + 3];176 // console.log("args: ", args);177 if(parseModes(op)[2] == '2') {178 targetIdx += state.rbase;179 }180 if (args[0] === args[1]) {181 return {182 ...state,183 pointer: state.pointer + 4,184 mem: set(state, targetIdx, 1).mem,185 };186 } else {187 return {188 ...state,189 pointer: state.pointer + 4,190 mem: set(state, targetIdx, 0).mem,191 };192 }193 } else if (effectiveOp(op) === '09') { // Adjust Rbase194 return op09(state, op);195 }196}197const op09 = (state, op) => {198 const args = readArgs(state, 1, parseModes(op));199 return {200 ...state,201 pointer: state.pointer + 2,202 rbase: state.rbase + args[0],203 }204}205const runProgram = async (program, input, output) => {206 let state = {207 pointer: 0,208 mem: program,209 rbase: 0,210 backingMem: {},211 }212 while (state.pointer !== -1) {...

Full Screen

Full Screen

11.js

Source:11.js Github

copy

Full Screen

...50 op = String(op).padStart(2, '0');51 // Input52 if (effectiveOp(op) === '03') {53 let targetIdx = state.mem[state.pointer + 1];54 if (parseModes(op)[0] == '2') {55 targetIdx += state.rbase;56 }57 const value = input();58 return {59 ...state,60 pointer: state.pointer + 2,61 mem: set(state, targetIdx, value).mem,62 };63 } else if (effectiveOp(op) === '01') { // Sum64 const args = readArgs(state, 2, parseModes(op));65 let targetIdx = state.mem[state.pointer + 3];66 if(parseModes(op)[2] == '2') {67 targetIdx += state.rbase;68 }69 return {70 ...state,71 pointer: state.pointer + 4,72 mem: set(state, targetIdx, R.sum(args)).mem,73 };74 } else if (effectiveOp(op) === '02') { // Product75 const args = readArgs(state, 2, parseModes(op));76 let targetIdx = state.mem[state.pointer + 3];77 if(parseModes(op)[2] == '2') {78 targetIdx += state.rbase;79 }80 return {81 ...state,82 pointer: state.pointer + 4,83 mem: set(state, targetIdx, R.product(args)).mem,84 };85 } else if (effectiveOp(op) === '99') { // Exit86 console.log("Finished");87 return {88 ...state,89 pointer: -190 };91 } else if (effectiveOp(op) === '04') { // Output92 const args = readArgs(state, 1, parseModes(op));93 output(args[0]);94 return {95 ...state,96 pointer: state.pointer + 2,97 };98 } else if (effectiveOp(op) === '05') { // Jump If True99 const args = readArgs(state, 2, parseModes(op));100 if (args[0] !== 0) {101 return {102 ...state,103 pointer: args[1]104 };105 } else {106 return {107 ...state,108 pointer: state.pointer + 3,109 };110 }111 } else if (effectiveOp(op) === '06') { // Jump if False112 const args = readArgs(state, 2, parseModes(op));113 if (args[0] === 0) {114 return {115 ...state,116 pointer: args[1],117 };118 } else {119 return {120 ...state,121 pointer: state.pointer + 3,122 };123 }124 } else if (effectiveOp(op) === '07') { // less than125 const args = readArgs(state, 2, parseModes(op));126 let targetIdx = state.mem[state.pointer + 3];127 if(parseModes(op)[2] == '2') {128 targetIdx += state.rbase;129 }130 if (args[0] < args[1]) {131 return {132 ...state,133 pointer: state.pointer + 4,134 mem: set(state, targetIdx, 1).mem,135 };136 } else {137 return {138 ...state,139 pointer: state.pointer + 4,140 mem: set(state, targetIdx, 0).mem,141 };142 }143 } else if (effectiveOp(op) === '08') { // Equals144 const args = readArgs(state, 2, parseModes(op));145 let targetIdx = state.mem[state.pointer + 3];146 // console.log("args: ", args);147 if(parseModes(op)[2] == '2') {148 targetIdx += state.rbase;149 }150 if (args[0] === args[1]) {151 return {152 ...state,153 pointer: state.pointer + 4,154 mem: set(state, targetIdx, 1).mem,155 };156 } else {157 return {158 ...state,159 pointer: state.pointer + 4,160 mem: set(state, targetIdx, 0).mem,161 };162 }163 } else if (effectiveOp(op) === '09') { // Adjust Rbase164 return op09(state, op);165 }166}167const op09 = (state, op) => {168 const args = readArgs(state, 1, parseModes(op));169 return {170 ...state,171 pointer: state.pointer + 2,172 rbase: state.rbase + args[0],173 }174}175const runProgram = (program) => {176 let state = {177 pointer: 0,178 mem: program,179 rbase: 0,180 backingMem: {},181 pos: [0, 0],182 direction: 1,...

Full Screen

Full Screen

7.js

Source:7.js Github

copy

Full Screen

...35 pointer: state.pointer + 2,36 mem: R.update(targetIdx, value, state.mem),37 };38 } else if (effectiveOp(op) === '01') {39 const args = readArgs(state, 2, parseModes(op));40 // console.log("args: ", args);41 // console.log("setting index:", state.mem[state.pointer+3], " to", R.sum(args))42 return {43 pointer: state.pointer + 4,44 mem: R.update(state.mem[state.pointer + 3], R.sum(args), state.mem),45 };46 } else if (effectiveOp(op) === '02') {47 const args = readArgs(state, 2, parseModes(op));48 return {49 pointer: state.pointer + 4,50 mem: R.update(state.mem[state.pointer + 3], R.product(args), state.mem),51 };52 } else if (effectiveOp(op) === '99') {53 // console.log("Finished");54 return {55 ...state,56 pointer: -157 };58 } else if (effectiveOp(op) === '04') {59 output(state.mem[state.mem[state.pointer + 1]]);60 return {61 ...state,62 pointer: state.pointer + 2,63 };64 } else if (effectiveOp(op) === '05') {65 const args = readArgs(state, 2, parseModes(op));66 if (args[0] !== 0) {67 return {68 ...state,69 pointer: args[1]70 };71 } else {72 return {73 ...state,74 pointer: state.pointer + 3,75 };76 }77 } else if (effectiveOp(op) === '06') {78 const args = readArgs(state, 2, parseModes(op));79 if (args[0] === 0) {80 return {81 ...state,82 pointer: args[1],83 };84 } else {85 return {86 ...state,87 pointer: state.pointer + 3,88 };89 }90 } else if (effectiveOp(op) === '07') {91 const args = readArgs(state, 2, parseModes(op));92 if (args[0] < args[1]) {93 return {94 pointer: state.pointer + 4,95 mem: R.update(state.mem[state.pointer + 3], 1, state.mem),96 };97 } else {98 return {99 pointer: state.pointer + 4,100 mem: R.update(state.mem[state.pointer + 3], 0, state.mem),101 };102 }103 } else if (effectiveOp(op) === '08') {104 const args = readArgs(state, 2, parseModes(op));105 if (args[0] === args[1]) {106 return {107 pointer: state.pointer + 4,108 mem: R.update(state.mem[state.pointer + 3], 1, state.mem),109 };110 } else {111 return {112 pointer: state.pointer + 4,113 mem: R.update(state.mem[state.pointer + 3], 0, state.mem),114 };115 }116 }117}118const runProgram = (program, input, output) => {...

Full Screen

Full Screen

17.js

Source:17.js Github

copy

Full Screen

...50 op = String(op).padStart(2, '0');51 // Input52 if (effectiveOp(op) === '03') {53 let targetIdx = state.mem[state.pointer + 1];54 if (parseModes(op)[0] == '2') {55 targetIdx += state.rbase;56 }57 const value = await input();58 return {59 ...state,60 pointer: state.pointer + 2,61 mem: set(state, targetIdx, value).mem,62 };63 } else if (effectiveOp(op) === '01') { // Sum64 const args = readArgs(state, 2, parseModes(op));65 let targetIdx = state.mem[state.pointer + 3];66 if(parseModes(op)[2] == '2') {67 targetIdx += state.rbase;68 }69 return {70 ...state,71 pointer: state.pointer + 4,72 mem: set(state, targetIdx, R.sum(args)).mem,73 };74 } else if (effectiveOp(op) === '02') { // Product75 const args = readArgs(state, 2, parseModes(op));76 let targetIdx = state.mem[state.pointer + 3];77 if(parseModes(op)[2] == '2') {78 targetIdx += state.rbase;79 }80 return {81 ...state,82 pointer: state.pointer + 4,83 mem: set(state, targetIdx, R.product(args)).mem,84 };85 } else if (effectiveOp(op) === '99') { // Exit86 console.log("Finished");87 return {88 ...state,89 pointer: -190 };91 } else if (effectiveOp(op) === '04') { // Output92 const args = readArgs(state, 1, parseModes(op));93 output(args[0]);94 return {95 ...state,96 pointer: state.pointer + 2,97 };98 } else if (effectiveOp(op) === '05') { // Jump If True99 const args = readArgs(state, 2, parseModes(op));100 if (args[0] !== 0) {101 return {102 ...state,103 pointer: args[1]104 };105 } else {106 return {107 ...state,108 pointer: state.pointer + 3,109 };110 }111 } else if (effectiveOp(op) === '06') { // Jump if False112 const args = readArgs(state, 2, parseModes(op));113 if (args[0] === 0) {114 return {115 ...state,116 pointer: args[1],117 };118 } else {119 return {120 ...state,121 pointer: state.pointer + 3,122 };123 }124 } else if (effectiveOp(op) === '07') { // less than125 const args = readArgs(state, 2, parseModes(op));126 let targetIdx = state.mem[state.pointer + 3];127 if(parseModes(op)[2] == '2') {128 targetIdx += state.rbase;129 }130 if (args[0] < args[1]) {131 return {132 ...state,133 pointer: state.pointer + 4,134 mem: set(state, targetIdx, 1).mem,135 };136 } else {137 return {138 ...state,139 pointer: state.pointer + 4,140 mem: set(state, targetIdx, 0).mem,141 };142 }143 } else if (effectiveOp(op) === '08') { // Equals144 const args = readArgs(state, 2, parseModes(op));145 let targetIdx = state.mem[state.pointer + 3];146 // console.log("args: ", args);147 if(parseModes(op)[2] == '2') {148 targetIdx += state.rbase;149 }150 if (args[0] === args[1]) {151 return {152 ...state,153 pointer: state.pointer + 4,154 mem: set(state, targetIdx, 1).mem,155 };156 } else {157 return {158 ...state,159 pointer: state.pointer + 4,160 mem: set(state, targetIdx, 0).mem,161 };162 }163 } else if (effectiveOp(op) === '09') { // Adjust Rbase164 return op09(state, op);165 }166}167const op09 = (state, op) => {168 const args = readArgs(state, 1, parseModes(op));169 return {170 ...state,171 pointer: state.pointer + 2,172 rbase: state.rbase + args[0],173 }174}175const runProgram = async (program, input, output) => {176 let state = {177 pointer: 0,178 mem: program,179 rbase: 0,180 backingMem: {},181 }182 while (state.pointer !== -1) {...

Full Screen

Full Screen

9.js

Source:9.js Github

copy

Full Screen

...50 op = String(op).padStart(2, '0');51 // Input52 if (effectiveOp(op) === '03') {53 let targetIdx = state.mem[state.pointer + 1];54 if (parseModes(op)[0] == '2') {55 targetIdx += state.rbase;56 }57 const value = input();58 return {59 ...state,60 pointer: state.pointer + 2,61 mem: set(state, targetIdx, value).mem,62 };63 } else if (effectiveOp(op) === '01') { // Sum64 const args = readArgs(state, 2, parseModes(op));65 let targetIdx = state.mem[state.pointer + 3];66 if(parseModes(op)[2] == '2') {67 targetIdx += state.rbase;68 }69 return {70 ...state,71 pointer: state.pointer + 4,72 mem: set(state, targetIdx, R.sum(args)).mem,73 };74 } else if (effectiveOp(op) === '02') { // Product75 const args = readArgs(state, 2, parseModes(op));76 let targetIdx = state.mem[state.pointer + 3];77 if(parseModes(op)[2] == '2') {78 targetIdx += state.rbase;79 }80 return {81 ...state,82 pointer: state.pointer + 4,83 mem: set(state, targetIdx, R.product(args)).mem,84 };85 } else if (effectiveOp(op) === '99') { // Exit86 console.log("Finished");87 return {88 ...state,89 pointer: -190 };91 } else if (effectiveOp(op) === '04') { // Output92 const args = readArgs(state, 1, parseModes(op));93 output(args[0]);94 return {95 ...state,96 pointer: state.pointer + 2,97 };98 } else if (effectiveOp(op) === '05') { // Jump If True99 const args = readArgs(state, 2, parseModes(op));100 if (args[0] !== 0) {101 return {102 ...state,103 pointer: args[1]104 };105 } else {106 return {107 ...state,108 pointer: state.pointer + 3,109 };110 }111 } else if (effectiveOp(op) === '06') { // Jump if False112 const args = readArgs(state, 2, parseModes(op));113 if (args[0] === 0) {114 return {115 ...state,116 pointer: args[1],117 };118 } else {119 return {120 ...state,121 pointer: state.pointer + 3,122 };123 }124 } else if (effectiveOp(op) === '07') { // less than125 const args = readArgs(state, 2, parseModes(op));126 let targetIdx = state.mem[state.pointer + 3];127 if(parseModes(op)[2] == '2') {128 targetIdx += state.rbase;129 }130 if (args[0] < args[1]) {131 return {132 ...state,133 pointer: state.pointer + 4,134 mem: set(state, targetIdx, 1).mem,135 };136 } else {137 return {138 ...state,139 pointer: state.pointer + 4,140 mem: set(state, targetIdx, 0).mem,141 };142 }143 } else if (effectiveOp(op) === '08') { // Equals144 const args = readArgs(state, 2, parseModes(op));145 let targetIdx = state.mem[state.pointer + 3];146 // console.log("args: ", args);147 if(parseModes(op)[2] == '2') {148 targetIdx += state.rbase;149 }150 if (args[0] === args[1]) {151 return {152 ...state,153 pointer: state.pointer + 4,154 mem: set(state, targetIdx, 1).mem,155 };156 } else {157 return {158 ...state,159 pointer: state.pointer + 4,160 mem: set(state, targetIdx, 0).mem,161 };162 }163 } else if (effectiveOp(op) === '09') { // Adjust Rbase164 return op09(state, op);165 }166}167const op09 = (state, op) => {168 const args = readArgs(state, 1, parseModes(op));169 return {170 ...state,171 pointer: state.pointer + 2,172 rbase: state.rbase + args[0],173 }174}175const runProgram = (program, input, output) => {176 let state = {177 pointer: 0,178 mem: program,179 rbase: 0,180 backingMem: {},181 }182 while (state.pointer !== -1) {...

Full Screen

Full Screen

2.2.sneak.js

Source:2.2.sneak.js Github

copy

Full Screen

...35 pointer: state.pointer + 2,36 mem: R.update(targetIdx, value, state.mem),37 };38 } else if (effectiveOp(op) === '01') {39 const args = readArgs(state, 2, parseModes(op));40 console.log(args);41 return {42 pointer: state.pointer + 4,43 // mem: R.update(state.mem[state.pointer + 3], R.sum(args), state.mem),44 mem: R.update(state.mem[state.pointer + 3],45 !isNaN(args[0]) && !isNaN(args[1]) ? Number(args[0]) + Number(args[1]) : '(' + args[0] + ' + ' + args[1] + ')',46 state.mem),47 };48 } else if (effectiveOp(op) === '02') {49 const args = readArgs(state, 2, parseModes(op));50 console.log(args);51 return {52 pointer: state.pointer + 4,53 // mem: R.update(state.mem[state.pointer + 3], R.product(args), state.mem),54 mem: R.update(state.mem[state.pointer + 3],55 !isNaN(args[0]) && !isNaN(args[1]) ? Number(args[0]) * Number(args[1]) : '(' + args[0] + ')' + '(' + args[1] + ')',56 state.mem),57 };58 } else if (effectiveOp(op) === '99') {59 console.log("Finished");60 return {61 ...state,62 pointer: -163 };64 } else if (effectiveOp(op) === '04') {65 output(state.mem[state.mem[state.pointer + 1]]);66 return {67 ...state,68 pointer: state.pointer + 2,69 };70 } else if (effectiveOp(op) === '05') {71 const args = readArgs(state, 2, parseModes(op));72 if (args[0] !== 0) {73 return {74 ...state,75 pointer: args[1]76 };77 } else {78 return {79 ...state,80 pointer: state.pointer + 3,81 };82 }83 } else if (effectiveOp(op) === '06') {84 const args = readArgs(state, 2, parseModes(op));85 if (args[0] === 0) {86 return {87 ...state,88 pointer: args[1],89 };90 } else {91 return {92 ...state,93 pointer: state.pointer + 3,94 };95 }96 } else if (effectiveOp(op) === '07') {97 const args = readArgs(state, 2, parseModes(op));98 if (args[0] < args[1]) {99 return {100 pointer: state.pointer + 4,101 mem: R.update(state.mem[state.pointer + 3], 1, state.mem),102 };103 } else {104 return {105 pointer: state.pointer + 4,106 mem: R.update(state.mem[state.pointer + 3], 0, state.mem),107 };108 }109 } else if (effectiveOp(op) === '08') {110 const args = readArgs(state, 2, parseModes(op));111 if (args[0] === args[1]) {112 return {113 pointer: state.pointer + 4,114 mem: R.update(state.mem[state.pointer + 3], 1, state.mem),115 };116 } else {117 return {118 pointer: state.pointer + 4,119 mem: R.update(state.mem[state.pointer + 3], 0, state.mem),120 };121 }122 }123}124const runProgram = (program, input, output) => {...

Full Screen

Full Screen

5.js

Source:5.js Github

copy

Full Screen

...33 const value = getInput();34 state.mem[targetIdx] = value;35 state.pointer = state.pointer + 2;36 } else if (effectiveOp(op) === '01') {37 const args = readArgs(state, 2, parseModes(op));38 state.mem[state.mem[state.pointer + 3]] = R.sum(args);39 state.pointer = state.pointer + 4;40 } else if (effectiveOp(op) === '02') {41 const args = readArgs(state, 2, parseModes(op));42 state.mem[state.mem[state.pointer + 3]] = R.product(args);43 state.pointer = state.pointer + 4;44 } else if (effectiveOp(op) === '99') {45 console.log("Finished");46 state.pointer = -1;47 } else if (effectiveOp(op) === '04') {48 output(state.mem[state.mem[state.pointer + 1]]);49 state.pointer = state.pointer + 2;50 } else if (effectiveOp(op) === '05') {51 const args = readArgs(state, 2, parseModes(op));52 if (args[0] !== 0) {53 state.pointer = args[1];54 } else {55 state.pointer = state.pointer + 3;56 }57 } else if (effectiveOp(op) === '06') {58 const args = readArgs(state, 2, parseModes(op));59 if (args[0] === 0) {60 state.pointer = args[1];61 } else {62 state.pointer = state.pointer + 3;63 }64 } else if (effectiveOp(op) === '07') {65 const args = readArgs(state, 2, parseModes(op));66 if (args[0] < args[1]) {67 state.mem[state.mem[state.pointer + 3]] = 1;68 } else {69 state.mem[state.mem[state.pointer + 3]] = 0;70 }71 state.pointer = state.pointer + 4;72 } else if (effectiveOp(op) === '08') {73 const args = readArgs(state, 2, parseModes(op));74 if (args[0] === args[1]) {75 state.mem[state.mem[state.pointer + 3]] = 1;76 } else {77 state.mem[state.mem[state.pointer + 3]] = 0;78 }79 state.pointer = state.pointer + 4;80 }81}82const runProgram = (program) => {83 const state = {84 pointer: 0,85 mem: program,86 }87 while (state.pointer !== -1) {...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { parseModes } from 'testcafe';2import { Selector } from 'testcafe';3test('My first test', async t => {4 .typeText('#developer-name', 'John Smith')5 .click('#submit-button');6 const articleHeader = await Selector('.result-content').find('h1');7 let headerText = await articleHeader.innerText;8});9const modes = parseModes(process.argv.slice(2));10console.log(modes);11const modes = parseModes(process.argv.slice(2));12console.log(modes);13const modes = parseModes(process.argv.slice(2));14console.log(modes);15const modes = parseModes(process.argv.slice(2));16console.log(modes);17const modes = parseModes(process.argv.slice(2));18console.log(modes);19const modes = parseModes(process.argv.slice(2));20console.log(modes);

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2test('My Test', async t => {3 const developerNameInput = Selector('#developer-name');4 .typeText(developerNameInput, 'Peter')5 .expect(developerNameInput.value).eql('Peter');6});7import { Selector } from 'testcafe';8test('My Test', async t => {9 const developerNameInput = Selector('#developer-name');10 .typeText(developerNameInput, 'Peter')11 .expect(developerNameInput.value).eql('Peter');12});13import { Selector } from 'testcafe';14test('My Test', async t => {15 const developerNameInput = Selector('#developer-name');16 .typeText(developerNameInput, 'Peter')17 .expect(developerNameInput.value).eql('Peter');18});19import { Selector } from 'testcafe';20test('My Test', async t => {21 const developerNameInput = Selector('#developer-name');22 .typeText(developerNameInput, 'Peter')23 .expect(developerNameInput.value).eql('Peter');24});25import { Selector } from 'testcafe';26test('My Test', async t => {27 const developerNameInput = Selector('#developer-name');28 .typeText(developerNameInput, 'Peter')29 .expect(developerNameInput.value).eql('Peter');30});31import { Selector

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2test('My first test', async t => {3});4export default class Test {5 constructor() {6 this.nameInput = Selector('#developer-name');7 this.submitButton = Selector('#submit-button');8 }9}10import { Selector } from 'testcafe';11import Test from './test';12const test = new Test();13test('My first test', async t => {14});15export default class Test {16 constructor() {17 this.nameInput = Selector('#developer-name');18 this.submitButton = Selector('#submit-button');19 }20}21{22 "compileOpts": {23 }24}

Full Screen

Using AI Code Generation

copy

Full Screen

1import { parseModes } from 'testcafe';2 .meta('skip', 'true')3 ('My test', async t => {4 });5const modes = parseModes(process.argv);6if (modes.skip) {7 fixture.skip('My fixture', () => {});8}9if (modes.only) {10 fixture.only('My fixture', () => {});11}12if (modes.skip) {13 test.skip('My test', () => {});14}15if (modes.only) {16 test.only('My test', () => {});17}18if (modes.debug) {19 ('My test', () => {});20}21if (modes.speed) {22 .speed(modes.speed)23 ('My test', () => {});24}25if (modes.debug) {26 .before(() => {})27 .after(() => {})28 .beforeEach(() => {})29 .afterEach(() => {})30 ('My test', () => {});31}32if (modes.skipJsErrors) {33 ('My test', () => {});34}35if (modes.skipUncaughtErrors) {36 ('My test', () =>

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2const testControllerHolder = require('./testControllerHolder');3test('My first test', async t => {4 .typeText('#developer-name', 'John Smith')5 .click('#submit-button');6 const articleHeader = await Selector('.result-content').find('h1');7 let headerText = await articleHeader.innerText;8 let headerHTML = await articleHeader.innerHTML;9 console.log('Header text: ' + headerText);10 console.log('Header HTML: ' + headerHTML);11});12const createTestCafe = require('testcafe');13let testcafe = null;14createTestCafe('localhost', 1337, 1338)15 .then(tc => {16 testcafe = tc;17 const runner = testcafe.createRunner();18 .src('./test.js')19 .browsers('chrome')20 .run();21 })22 .then(failedCount => {23 console.log('Tests failed: ' + failedCount);24 testcafe.close();25 });26const createTestCafe = require('testcafe');27let testcafe = null;28createTestCafe('localhost', 1337, 1338)29 .then(tc => {30 testcafe = tc;31 const runner = testcafe.createRunner();32 .src('./test.js')33 .browsers('chrome')34 .run();35 })36 .then(failedCount => {37 console.log('Tests failed: ' + failedCount);38 testcafe.close();39 });40const createTestCafe = require('testcafe');41let testcafe = null;42createTestCafe('localhost', 1337, 1338)43 .then(tc => {44 testcafe = tc;45 const runner = testcafe.createRunner();46 .src('./test.js')47 .browsers('chrome')48 .run();49 })50 .then(failedCount

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector, t } from 'testcafe';2test('My first test', async t => {3 const developerNameInput = Selector('#developer-name');4 .typeText(developerNameInput, 'Peter')5 .click('#submit-button')6 .expect(Selector('#article-header').innerText).eql('Thank you, Peter!');7});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { ClientFunction } from 'testcafe';2const getParseModes = ClientFunction(() => {3 return window.parseModes;4});5test('My first test', async t => {6 const parseModes = await getParseModes();7 console.log(parseModes);8});9import { ClientFunction } from 'testcafe';10const getParseModes = ClientFunction(() => {11 return window.parseModes;12});13test('My first test', async t => {14 const parseModes = await getParseModes();15 console.log(parseModes);16});17import { ClientFunction } from 'testcafe';18const getParseModes = ClientFunction(() => {19 return window.parseModes;20});21test('My first test', async t => {22 const parseModes = await getParseModes();23 console.log(parseModes);24});25import { ClientFunction } from 'testcafe';26const getParseModes = ClientFunction(() => {27 return window.parseModes;28});29test('My first test', async t => {30 const parseModes = await getParseModes();31 console.log(parseModes);32});33import { ClientFunction } from 'testcafe';34const getParseModes = ClientFunction(() => {35 return window.parseModes;36});37test('My first test', async t => {38 const parseModes = await getParseModes();39 console.log(parseModes);40});41import { ClientFunction } from 'testcafe';

Full Screen

Using AI Code Generation

copy

Full Screen

1import { parseModes } from 'testcafe';2test('My first test', async t => {3 const modes = parseModes('desktop:chrome;mobile:iphone;tablet:ipad');4 .typeText('#developer-name', 'John Smith')5 .click('#submit-button');6});7const modes = parseModes('desktop:chrome;mobile:iphone;tablet:ipad');8 .typeText('#developer-name', 'John Smith')9 .click('#submit-button');

Full Screen

Using AI Code Generation

copy

Full Screen

1import { parseModes } from 'testcafe';2const mode = parseModes('testcafe');3const mode = parseModes('testcafe', 'testcafe');4const mode = parseModes('testcafe', 'testcafe', 'testcafe');5const mode = parseModes('testcafe', 'testcafe', 'testcafe', 'testcafe');6const mode = parseModes('testcafe', 'testcafe', 'testcafe', 'testcafe', 'testcafe');7const mode = parseModes('testcafe', 'testcafe', 'testcafe', 'testcafe', 'testcafe', 'testcafe');8const mode = parseModes('testcafe', 'testcafe', 'testcafe', 'testcafe', 'testcafe', 'testcafe', 'testcafe');

Full Screen

Using AI Code Generation

copy

Full Screen

1const parseModes = require('testcafe/lib/utils/parse-modes');2const mode = parseModes('chrome --headless --no-sandbox');3console.log(mode);4{ browser: 'chrome',5 isMultiBrowser: false }6const getBrowserInfo = require('testcafe/lib/utils/browser-info');7const browserInfo = getBrowserInfo('chrome --headless --no-sandbox');8console.log(browserInfo);9{ alias: 'chrome',10 isMultiBrowser: false }11const parseBrowserList = require('testcafe/lib/utils/browser-list');12const browserList = parseBrowserList('chrome:headless --no-sandbox');13console.log(browserList);14[ { alias: 'chrome',15 isMultiBrowser: false } ]16const getBrowserList = require('testcafe/lib/utils/browser-list');17const browserList = getBrowserList('chrome:headless --no-sandbox');18console.log(browserList);19[ { alias: 'chrome',20 isMultiBrowser: false } ]21const getBrowserId = require('testcafe/lib/utils/browser-id');22const browserId = getBrowserId('chrome');23console.log(browserId);24const getBrowserName = require('testcafe/lib/utils/browser-name');25const browserName = getBrowserName('chrome');26console.log(browserName);27const parseUserAgent = require('testcafe/lib/utils/parse-user-agent');28const userAgent = parseUserAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Testcafe automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful