From 55fb26bb22bdf23e97423ae37e4bce604ed13018 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=E1=BB=B3nh=20Tr=E1=BA=A7n=20Khanh?= Date: Fri, 27 Oct 2023 04:09:21 +0000 Subject: [PATCH] Fix test --- compiler/cppCodegen.test.js | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/compiler/cppCodegen.test.js b/compiler/cppCodegen.test.js index 5de611d..33d9b6a 100644 --- a/compiler/cppCodegen.test.js +++ b/compiler/cppCodegen.test.js @@ -31,6 +31,9 @@ procedure("fibonacci", { n: int32, a: int32, b: int32, i: int32 }, () => { divide(2, 3) sDivide(1, 2) + divide(readChar(), coerceInt8(3)) + sDivide(readChar(), readChar()) + call("pointless", { preset: 100 }) call("pointless", {}) @@ -41,6 +44,8 @@ procedure("fibonacci", { n: int32, a: int32, b: int32, i: int32 }, () => { if (less(get("n"), 200) || true && !false) { writeChar(100); } + + if (less(readChar() + readChar(), coerceInt8(3)) && sLess(readChar(), readChar())) {} });` const transformer = new CoqCPASTTransformer(code) @@ -76,23 +81,27 @@ int main() { local_2 = uint64_t(1); environment_0[uint64_t(0)] = { local_1 }; environment_0[uint64_t(1)] = { local_2 }; - for (uint64_t binder_0 = 0; binder_0 < binaryOp([&]() { return local_0; }, [&]() { return uint64_t(2); }, [&](auto a, auto b) { return a - b; }); binder_0++) { - local_3 = binaryOp([&]() { return get<0>(environment_0[binder_0]); }, [&]() { return get<0>(environment_0[binaryOp([&]() { return binder_0; }, [&]() { return uint64_t(1); }, [&](auto a, auto b) { return a + b; })]); }, [&](auto a, auto b) { return a + b; }); - environment_0[binaryOp([&]() { return binder_0; }, [&]() { return uint64_t(2); }, [&](auto a, auto b) { return a + b; })] = { local_3 }; + for (uint64_t binder_0 = 0; binder_0 < (local_0 - uint64_t(2)); binder_0++) { + local_3 = (get<0>(environment_0[binder_0]) + get<0>(environment_0[(binder_0 + uint64_t(1))])); + environment_0[(binder_0 + uint64_t(2))] = { local_3 }; break; continue; flushSTDOUT(); } - binaryOp([&]() { return uint64_t(2); }, [&]() { return uint64_t(3); }, [&](auto a, auto b) { return a / b; }); - binaryOp([&]() { return toSigned(uint64_t(1)); }, [&]() { return toSigned(uint64_t(2)); }, [&](auto a, auto b) { return a / b; }); + (uint64_t(2) / uint64_t(3)); + (toSigned(uint64_t(1)) / toSigned(uint64_t(2))); + binaryOp([&]() { return readChar(); }, [&]() { return uint8_t(uint64_t(3)); }, [&](auto a, auto b) { return a / b; }); + binaryOp([&]() { return toSigned(readChar()); }, [&]() { return toSigned(readChar()); }, [&](auto a, auto b) { return a / b; }); procedure_0(uint64_t(100)); procedure_0(0); - if (binaryOp([&]() { return local_0; }, [&]() { return uint64_t(100); }, [&](auto a, auto b) { return a == b; })) { + if ((local_0 == uint64_t(100))) { writeChar(uint64_t(32)); } - if (binaryOp([&]() { return local_0; }, [&]() { return uint64_t(200); }, [&](auto a, auto b) { return a < b; }) || true && (!false)) { + if ((local_0 < uint64_t(200)) || true && (!false)) { writeChar(uint64_t(100)); } + if (binaryOp([&]() { return binaryOp([&]() { return readChar(); }, [&]() { return readChar(); }, [&](auto a, auto b) { return a + b; }); }, [&]() { return uint8_t(uint64_t(3)); }, [&](auto a, auto b) { return a < b; }) && binaryOp([&]() { return toSigned(readChar()); }, [&]() { return toSigned(readChar()); }, [&](auto a, auto b) { return a < b; })) { + } }; }`) })