From 2e17188f2b485bc8288e2d855a98aff9489e4b14 Mon Sep 17 00:00:00 2001 From: kichikuou Date: Sat, 13 Jun 2020 15:18:44 +0900 Subject: [PATCH] Fix DI command and add tests --- src/cmdd.c | 8 ++++---- test/README.md | 5 +++++ test/test.adv | 11 +++++++++++ test/test.hed | 4 ++++ test/testSA.ALD | Bin 0 -> 1296 bytes test/testd.adv | 18 ++++++++++++++++++ test/util.adv | 16 ++++++++++++++++ test/xsys35c.cfg | 3 +++ 8 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 test/README.md create mode 100644 test/test.adv create mode 100644 test/test.hed create mode 100644 test/testSA.ALD create mode 100644 test/testd.adv create mode 100644 test/util.adv create mode 100644 test/xsys35c.cfg diff --git a/src/cmdd.c b/src/cmdd.c index 7647700..23dc620 100644 --- a/src/cmdd.c +++ b/src/cmdd.c @@ -41,13 +41,13 @@ void commandDC() { void commandDI() { int page = getCaliValue(); + int *var_use = getCaliVariable(); int *var_size = getCaliVariable(); - int *var_save = getCaliVariable(); - *var_size = v_releaseArrayVar(page); - *var_save = v_getArrayBufferCnt(page) == true ? 1 : 0; + *var_use = v_getArrayBufferStatus(page); + *var_size = (v_getArrayBufferCnt(page) + 1) & 0xffff; - DEBUG_COMMAND("DI %d,%p,%p:\n", page, var_size, var_save); + DEBUG_COMMAND("DI %d,%p,%p:\n", page, var_use, var_size); } void commandDS() { diff --git a/test/README.md b/test/README.md new file mode 100644 index 0000000..13e4403 --- /dev/null +++ b/test/README.md @@ -0,0 +1,5 @@ +The test scenario file (`testSA.ALD`) in this directory should pass in both +xsystem35 and the original System 3.x. + +To build `testSA.ALD`, install [xsys35c](https://github.com/kichikuou/xsys35c) +and run `xsys35c` command in this directory. diff --git a/test/test.adv b/test/test.adv new file mode 100644 index 0000000..71056e9 --- /dev/null +++ b/test/test.adv @@ -0,0 +1,11 @@ + !RND:0! + !tests_passed:0! + !tests_failed:0! + ZH 2: + + %#testd.adv: + + HH0,tests_passed: ' tests passed' R + HH0,tests_failed: ' tests failed' R + {tests_failed: A} + ZZ0,0: diff --git a/test/test.hed b/test/test.hed new file mode 100644 index 0000000..0c8d99b --- /dev/null +++ b/test/test.hed @@ -0,0 +1,4 @@ +#SYSTEM35 +test.adv +util.adv +testd.adv diff --git a/test/testSA.ALD b/test/testSA.ALD new file mode 100644 index 0000000000000000000000000000000000000000..282377a10ee7921d27a11c21f05148499c2d9940 GIT binary patch literal 1296 zcmd^9O-sW-5S^_b)SEwHBNQ*C5xht*?zUChS}N3wR6K+xLLp!!sVD`fZPNBP_zV0Y z-aYzv>P*(93cc#36J|+X-oDLy0}%i@fGvP+fF0Pp5&}dH1O>2}CCT;!_4xJey{fPHku8vQREQhf?WDL)LGz@2~(3wzA6?W?tEL6}vfC;*eWMU)-UK9mBbO@cU z&^xamGCG=KNJ3ii+U~bA>wg&c!*%|dBdGI`F;@N)@}5%96pqqlgqle1 z?gR@8mAPlzH|M(1x|MLP>7fi1#*D)Vo(4fL4*arYC}qg&#X~PNK!P2TA;G^ZNzxzG z);|x;{}F(lKXd3u0eji}{gMs9nUnX0LibRk*~@Qg4UKbLpp(qM(>cSJ927~QR@K-< zg}*790&G}{lhDref}o~_YE@X`>C#-)XR1tsz|}FV(Y70m2G8ZvLTjUJw*>6dXW2i% E7u*1qF8}}l literal 0 HcmV?d00001 diff --git a/test/testd.adv b/test/testd.adv new file mode 100644 index 0000000..e7b29bb --- /dev/null +++ b/test/testd.adv @@ -0,0 +1,18 @@ + MS FILE,"testd.adv": + !used:0! + !size:0! + + DI 1,used,size: + ~AssertEqual used,0,__LINE__: + + DC 1,10,0: + DI 1,used,size: + ~AssertEqual used,1,__LINE__: + ~AssertEqual size,11,__LINE__: + + DC 255,65535,0: + DI 255,used,size: + ~AssertEqual used,1,__LINE__: + ~AssertEqual size,0,__LINE__: + + %0: diff --git a/test/util.adv b/test/util.adv new file mode 100644 index 0000000..3722bcb --- /dev/null +++ b/test/util.adv @@ -0,0 +1,16 @@ +const word FILE = 1: + !actual:0! + !expected:0! + !line:0! + +**AssertEqual actual,expected,line: + {expected = actual: + inc tests_passed: + %0: + } + inc tests_failed: + '[FAIL] ' X FILE: ':' HH0,line: + ' expected: ' HH0,expected: + ' actual: ' HH0,actual: + R + %0: diff --git a/test/xsys35c.cfg b/test/xsys35c.cfg new file mode 100644 index 0000000..dc5830b --- /dev/null +++ b/test/xsys35c.cfg @@ -0,0 +1,3 @@ +output_ald = testSA.ALD +sys_ver = 3.8 +hed = test.hed