Exemple #1
0
 def test_exec_do_times(self):
     i = '_exec_do*times'
     # 1
     before = {
         '_integer': [2],
         '_exec': [get_instruction('_string_stack_depth')]
     }
     after = {
         '_exec': [[
             0, 1,
             JustInTimeInstruction('_exec_do*range'),
             [
                 JustInTimeInstruction('_integer_pop'),
                 get_instruction('_string_stack_depth')
             ]
         ]]
     }
     self.assertTrue(t_u.run_test(before, after, i))
     # 2
     before = {'_integer': [2], '_exec': [get_instruction('_integer_inc')]}
     after = {
         '_exec': [[
             0, 1,
             JustInTimeInstruction('_exec_do*range'),
             [
                 JustInTimeInstruction('_integer_pop'),
                 get_instruction('_integer_inc')
             ]
         ]]
     }
     self.assertTrue(t_u.run_test(before, after, i))
Exemple #2
0
 def test_code_do_count(self):
     i = '_code_do*count'
     # 1
     before = {
         '_integer': [2],
         '_code': [get_instruction('_string_stack_depth')]
     }
     after = {
         '_exec': [[
             0, 1,
             JustInTimeInstruction('_code_from_exec'),
             get_instruction('_string_stack_depth'),
             JustInTimeInstruction('_code_do*range')
         ]]
     }
     self.assertTrue(t_u.run_test(before, after, i))
     # 2
     before = {'_integer': [2], '_code': [get_instruction('_integer_inc')]}
     after = {
         '_exec': [[
             0, 1,
             JustInTimeInstruction('_code_from_exec'),
             get_instruction('_integer_inc'),
             JustInTimeInstruction('_code_do*range')
         ]]
     }
     self.assertTrue(t_u.run_test(before, after, i))
Exemple #3
0
 def test_code_do_range(self):
     before = {
         '_code': [get_instruction('_integer_inc')],
         '_integer': [1, 2, 3]
     }
     after = {
         '_exec': [[
             3, 3,
             JustInTimeInstruction('_code_from_exec'),
             get_instruction('_integer_inc'),
             JustInTimeInstruction('_code_do*range')
         ],
                   get_instruction('_integer_inc')],
         '_integer': [1, 2]
     }
     self.assertTrue(t_u.run_test(before, after, '_code_do*range'))
Exemple #4
0
 def test_code_do(self):
     before = {'_code': [7], '_exec': []}
     after = {
         '_exec': [JustInTimeInstruction('_code_pop'), 7],
         '_code': [7]
     }
     self.assertTrue(t_u.run_test(before, after, '_code_do'))
Exemple #5
0
 def test_exec_while(self):
     i = '_exec_while'
     # 1
     before = {
         '_integer': [5],
         '_boolean': [True],
         '_exec': [get_instruction('_integer_inc')]
     }
     after = {
         '_integer': [5],
         '_exec': [
             get_instruction('_integer_inc'),
             JustInTimeInstruction('_exec_while'),
             get_instruction('_integer_inc')
         ]
     }
     self.assertTrue(t_u.run_test(before, after, i))
     # 2
     before = {
         '_integer': [5],
         '_boolean': [False],
         '_exec': [get_instruction('_integer_inc')]
     }
     after = {'_integer': [5]}
     self.assertTrue(t_u.run_test(before, after, i))
     # 3
     before = {
         '_boolean': [True],
         '_exec': [get_instruction('_string_stack_depth')]
     }
     after = {
         '_exec': [
             get_instruction('_string_stack_depth'),
             JustInTimeInstruction('_exec_while'),
             get_instruction('_string_stack_depth')
         ]
     }
     self.assertTrue(t_u.run_test(before, after, i))
     # 4
     before = {
         '_boolean': [False],
         '_exec': [get_instruction('_string_stack_depth')]
     }
     after = {}
     self.assertTrue(t_u.run_test(before, after, i))
Exemple #6
0
 def test_exec_do_range(self):
     before = {
         '_exec': [get_instruction('_integer_inc')],
         '_integer': [3, 4]
     }
     after = {
         '_exec': [[
             4, 4,
             JustInTimeInstruction('_exec_do*range'),
             get_instruction('_integer_inc')
         ],
                   get_instruction('_integer_inc')],
         '_integer': [3]
     }
     self.assertTrue(t_u.run_test(before, after, '_exec_do*range'))