SublimeKSP uses unittest for testing.
The documentation can be found here with instructions on how to run tests
We need tests to check if code if compiled correctly
We need tests to check if errors are identified correctly
Look at other tests for examples.
This is a good first issue if you are looking to contribute!
If you need any more guidance, feel free to contact me :))
Tests needed:
If you find any tests that are needed then please add!
Examples
Example for comparing outputs
class ForLoop(unittest.TestCase):
def testForLoopBasic(self):
code = '''
on init
declare i
for i := 0 to 10
message(i)
end for
end on'''
expected_output = '''
on init
declare $i
$i := 0
while ($i<=10)
message($i)
inc($i)
end while
end on'''
output = do_compile(code, remove_preprocessor_vars=True)
output = [l.strip() for l in output.split('\n') if l]
expected_output = [l.strip() for l in expected_output.split('\n') if l]
self.assertEqual(output, expected_output)
Example to check if a line is in the output
class PropertyTests(unittest.TestCase):
def testAlias1(self):
code = '''
on init
declare a
property b -> a
message(b)
end on
'''
output = do_compile(code)
self.assertTrue('message($a)' in output)
Example to check if an error raised
class TypeChecks(unittest.TestCase):
def testAssignStringToIntVar1(self):
code = '''
on init
declare x := 'test'
end on'''
self.assertRaises(ParseException, do_compile, code, extra_syntax_checks=True)
SublimeKSP uses unittest for testing.
The documentation can be found here with instructions on how to run tests
We need tests to check if code if compiled correctly
We need tests to check if errors are identified correctly
Look at other tests for examples.
This is a good first issue if you are looking to contribute!
If you need any more guidance, feel free to contact me :))
Tests needed:
If you find any tests that are needed then please add!
Examples
Example for comparing outputs
Example to check if a line is in the output
Example to check if an error raised