aboutsummaryrefslogtreecommitdiff
path: root/test/test_jsinterp.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_jsinterp.py')
-rw-r--r--test/test_jsinterp.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/test_jsinterp.py b/test/test_jsinterp.py
index 5121c8cf8..c47def737 100644
--- a/test/test_jsinterp.py
+++ b/test/test_jsinterp.py
@@ -158,6 +158,38 @@ class TestJSInterpreter(unittest.TestCase):
self.assertEqual(jsi.call_function('z'), 5)
self.assertEqual(jsi.call_function('y'), 2)
+ def test_if(self):
+ jsi = JSInterpreter('''
+ function x() {
+ let a = 9;
+ if (0==0) {a++}
+ return a
+ }''')
+ self.assertEqual(jsi.call_function('x'), 10)
+
+ jsi = JSInterpreter('''
+ function x() {
+ if (0==0) {return 10}
+ }''')
+ self.assertEqual(jsi.call_function('x'), 10)
+
+ jsi = JSInterpreter('''
+ function x() {
+ if (0!=0) {return 1}
+ else {return 10}
+ }''')
+ self.assertEqual(jsi.call_function('x'), 10)
+
+ """ # Unsupported
+ jsi = JSInterpreter('''
+ function x() {
+ if (0!=0) {return 1}
+ else if (1==0) {return 2}
+ else {return 10}
+ }''')
+ self.assertEqual(jsi.call_function('x'), 10)
+ """
+
def test_for_loop(self):
# function x() { a=0; for (i=0; i-10; i++) {a++} a }
jsi = JSInterpreter('''