plasma-umass / Ninia

Python interpreter in JavaScript
Other
20 stars 8 forks source link

Improve Test Code Coverage #17

Open jvilk opened 9 years ago

jvilk commented 9 years ago

This is a good starter task for Google Summer of Code students!

I just committed a change that lets us look at code coverage for our test suite.

You'll need to install the Istanbul code coverage tool:

npm install -g istanbul

Then, run make coverage, start a local http-server, and check out ./coverage/lcov-report/.

A large portion of our opcodes are not tested. Here's where you come in!

KRVPerera commented 9 years ago

I get a error message for make coverage :worried: src/builtins.ts(4,29): error TS2307: Cannot find external module './primitives'. Followed by several lines and I don't have a ./coverage folder

jvilk commented 9 years ago

Ack, I forgot to add the new primitives file in my last commit! Fixed.

perimosocordiae commented 9 years ago

Along these lines, I just added a whole bunch of tests for some of the opcodes we don't have implemented yet. We now fail 8 tests, which should cover the following (currently NYI) opcodes:

BREAK_LOOP
BUILD_CLASS
BUILD_SET
CALL_FUNCTION_KW
CALL_FUNCTION_VAR
CALL_FUNCTION_VAR_KW
INPLACE_DIVIDE
INPLACE_MULTIPLY
INPLACE_SUBTRACT
YIELD_VALUE
INPLACE_AND
INPLACE_FLOOR_DIVIDE
INPLACE_LSHIFT
INPLACE_MODULO
INPLACE_OR
INPLACE_POWER
INPLACE_RSHIFT
INPLACE_TRUE_DIVIDE
INPLACE_XOR
DELETE_ATTR
DELETE_FAST
DELETE_GLOBAL
DELETE_NAME
DELETE_SLICE_0
DELETE_SLICE_1
DELETE_SLICE_2
DELETE_SLICE_3
CONTINUE_LOOP

These opcodes are also NYI, and still need test coverage:

DUP_TOPX
END_FINALLY
EXEC_STMT
EXTENDED_ARG
IMPORT_STAR
LIST_APPEND
LOAD_LOCALS
MAP_ADD
PRINT_EXPR
PRINT_ITEM_TO
PRINT_NEWLINE_TO
RAISE_VARARGS
SET_ADD
SETUP_EXCEPT
SETUP_FINALLY
SETUP_WITH
STORE_ATTR
STORE_DEREF
WITH_CLEANUP
perimosocordiae commented 9 years ago

FYI: I was looking into the CONTINUE_LOOP opcode, and I can't seem to get python to generate one.

geremih commented 9 years ago

CONTINUE_LOOP is used when continue is called within a try/catch/finally block. Try this out,

for i in xrange(10):
    try:
        continue
    finally:
        pass