Changeset - 41be60d4fd30
[Not reviewed]
default
0 0 2
Laman - 2 years ago 2023-01-01 14:21:55

a test for the basic case
2 files changed with 22 insertions and 0 deletions:
0 comments (0 inline, 0 general)
tests/__init__.py
Show inline comments
 
new file 100644
tests/test_jasinta.py
Show inline comments
 
new file 100644
 
from unittest import TestCase
 
from unittest.mock import MagicMock
 

	
 
from pyjsparser import parse
 

	
 
from jasinta import interpret
 
import std as jasinta_std
 

	
 

	
 
class TestBasicAddition(TestCase):
 
	def setUp(self):
 
		self.mock_print = MagicMock()
 
		jasinta_std.lib["document"]["write"] = self.mock_print
 

	
 
	def test_interpret(self):
 
		s = """var a=3;
 
var b=1;
 
var c=a+b;
 
document.write(c);"""
 

	
 
		interpret(parse(s))
 
		self.mock_print.assert_called_with(4.0)
0 comments (0 inline, 0 general)