From e642a25dd4d7c39d342d3660996f00981d7a6ad9 Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Mon, 19 Dec 2022 13:45:19 +0000 Subject: [PATCH] fix(calibrate): operand stack order --- --- a/tests/src/calibrate.ts +++ b/tests/src/calibrate.ts @@ -72,26 +72,26 @@ } else if (op === '+') { if (stack.length < 2) throw new Error('stack underflow'); + const b = stack.pop()!; const a = stack.pop()!; - const b = stack.pop()!; stack.push(a.plus(b)); } else if (op === '*') { if (stack.length < 2) throw new Error('stack underflow'); + const b = stack.pop()!; const a = stack.pop()!; - const b = stack.pop()!; stack.push(a.mul(b)); } else if (op === '-') { if (stack.length < 2) throw new Error('stack underflow'); + const b = stack.pop()!; const a = stack.pop()!; - const b = stack.pop()!; stack.push(a.minus(b)); } else if (op === '/') { if (stack.length < 2) throw new Error('stack underflow'); + const b = stack.pop()!; const a = stack.pop()!; - const b = stack.pop()!; stack.push(a.div(b)); } else if (op === 'dup') { if (stack.length < 1) -- gitstuff