Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test cases of QuickJS execution failed #65

Open
haigithub opened this issue Sep 20, 2023 · 2 comments
Open

Test cases of QuickJS execution failed #65

haigithub opened this issue Sep 20, 2023 · 2 comments

Comments

@haigithub
Copy link

Problem Description:
I found that some test cases in repo QuickJS failed to execute.

Expectation:
All test cases in the directory tests/ of QuickJS would succeed to execute.

Actual test results:

command test result remark
./qjs path/to/quickjs/tests/microbench.js pass -
./qjs path/to/quickjs/tests/test_builtin.js pass -
./qjs path/to/quickjs/tests/test_std.js pass -
./qjs path/to/quickjs/tests/test_bignum.js failed Error: SyntaxError: invalid number literal
./qjs path/to/quickjs/tests/test_closure.js failed Error: SyntaxError: invalid keyword: with
./qjs path/to/quickjs/tests/test_language.js failed Error: SyntaxError: invalid keyword: with
./qjs path/to/quickjs/tests/test_loop.js failed Error: SyntaxError: a declaration in the head of a for-in loop can't have an initializer
./qjs path/to/quickjs/tests/test_worker.js failed SegmentFault
./qjs path/to/quickjs/tests/test_op_overloading.js failed Error: ReferenceError: 'Operators' is not defined
./qjs path/to/quickjs/tests/test_qjscalc.js failed Error: Error: assertion failed: got

test_bignum.js
Error: SyntaxError: invalid number literal
at /home/oem/path/to/quickjs/tests/test_bignum.js:155

test_closure.js
Error: SyntaxError: invalid keyword: with
at /home/oem/path/to/quickjs/tests/test_closure.js:157

test_language.js
Error: SyntaxError: invalid keyword: with
at /home/oem/path/to/quickjs/tests/test_language.js:379

Error: SyntaxError: a declaration in the head of a for-in loop can't have an initializer
at /home/oem/path/to/quickjs/tests/test_loop.js:144

test_op_overloading.js
Error: ReferenceError: 'Operators' is not defined
at test_operators_create (/home/oem/path/to/quickjs/tests/test_op_overloading.js:39)
at (/home/oem/path/to/quickjs/tests/test_op_overloading.js:205)

test_qjscalc.js
Error: Error: assertion failed: got |false|, expected |true|
at assert (/home/oem/path/to/quickjs/tests/test_qjscalc.js:18)
at test_integer (/home/oem/path/to/quickjs/tests/test_qjscalc.js:52)
at (/home/oem/path/to/quickjs/tests/test_qjscalc.js:245)

Development environment: Ubuntu 20.04

Problem recurrence steps:

  1. Download QuickJS
git clone https://github.com/bellard/quickjs.git
git checkout b5e62895c619d4ffc75c9d822c8d85f1ece77e5b // checkout into the same version with quickjspp

git log
commit b5e62895c619d4ffc75c9d822c8d85f1ece77e5b (HEAD)
Author: bellard <6490144+bellard@users.noreply.github.com>
Date:   Sat Mar 27 11:17:31 2021 +0100

    2021-03-27 release
  1. Download and build quickjspp
git clone https://github.com/ftk/quickjspp.git
cd quickjspp/
mkdir build
cd build/
cmake ..
make -j16
  1. run test cases
cd quickjspp/build/
./qjs path/to/quickjs/tests/xxx.js
@ftk
Copy link
Owner

ftk commented Sep 20, 2023

qjs.cpp is actually a very simplified version of qjs.c from quickjs repo. For example, it always evaluates scripts in 'module' mode.
After a simple patch a few more tests are now working.

diff --git a/qjs.cpp b/qjs.cpp
index 70e215c..6004c25 100644
--- a/qjs.cpp
+++ b/qjs.cpp
@@ -31,7 +31,7 @@ int main(int argc, char ** argv)
     try
     {
         if(argv[1])
-            context.evalFile(argv[1], JS_EVAL_TYPE_MODULE);
+            context.evalFile(argv[1], 0);
     }
     catch(exception & e)
     {

@haigithub
Copy link
Author

Other js scripts would execute failed with context.evalFile(argv[1], 0);

command test result remark
./qjs path/to/quickjs/tests/microbench.js failed see below
./qjs path/to/quickjs/tests/test_builtin.js pass -
./qjs path/to/quickjs/tests/test_std.js failed see below
./qjs path/to/quickjs/tests/test_bignum.js failed see below
./qjs path/to/quickjs/tests/test_closure.js pass -
./qjs path/to/quickjs/tests/test_language.js pass -
./qjs path/to/quickjs/tests/test_loop.js pass -
./qjs path/to/quickjs/tests/test_worker.js failed see below
./qjs path/to/quickjs/tests/test_op_overloading.js failed see below
./qjs path/to/quickjs/tests/test_qjscalc.js failed see below

./qjs ~/wslumi.gateway.mgl03/quickjs/tests/microbench.js
Error: SyntaxError: expecting '('
at path/to/quickjs/tests/microbench.js:25

./qjs ~/wslumi.gateway.mgl03/quickjs/tests/test_std.js
Error: SyntaxError: expecting '('
at path/to/quickjs/tests/test_std.js:1

./qjs ~/wslumi.gateway.mgl03/quickjs/tests/test_bignum.js
Error: SyntaxError: invalid number literal
at path/to/quickjs/tests/test_bignum.js:155

./qjs ~/wslumi.gateway.mgl03/quickjs/tests/test_worker.js
Error: SyntaxError: expecting '('
at path/to/quickjs/tests/test_worker.js:2

./qjs ~/wslumi.gateway.mgl03/quickjs/tests/test_op_overloading.js
Error: ReferenceError: 'Operators' is not defined
at test_operators_create (path/to/quickjs/tests/test_op_overloading.js:39)
at (path/to/quickjs/tests/test_op_overloading.js:205)

./qjs ~/wslumi.gateway.mgl03/quickjs/tests/test_qjscalc.js
Error: Error: assertion failed: got |false|, expected |true|
at assert (path/to/quickjs/tests/test_qjscalc.js:18)
at test_integer (path/to/quickjs/tests/test_qjscalc.js:52)
at (path/to/quickjs/tests/test_qjscalc.js:245)

ftk added a commit that referenced this issue Dec 21, 2023
… quickjs/qjs.c interpreter

should fix some issues with quickjs tests failing (#65)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants