Beispiel #1
0
 def test_step8_repl_env_isolation(self):
     env1 = step8_macros.init_repl_env()
     step8_macros.rep("(def! a 2)", env1)
     env2 = step8_macros.init_repl_env()
     step8_macros.rep("(def! a 3)", env2)
     self.assertEqual("2", step8_macros.rep("a", env1))
     self.assertEqual("3", step8_macros.rep("a", env2))
     self.assertEqual("6", step8_macros.rep("(eval (list + a 3))", env2))
Beispiel #2
0
 def run_mal(self, test_files):
     for test_file in test_files:
         test_basename = test_file.name
         cwd = Path.cwd()
         try:
             os.chdir(TEST_DIR)
             repl_env = rep.init_repl_env(argv=[])
             with self.subTest(test_file=test_basename):
                 self.run_tests(
                     test_file,
                     functools.partial(rep.rep, env=repl_env),
                     hard=True,
                 )
         finally:
             os.chdir(cwd)
Beispiel #3
0
 def test_native(self):
     for test_file in sorted(TEST_DIR.glob("native*.mal")):
         test_basename = Path(test_file).name
         cwd = Path.cwd()
         try:
             os.chdir(Path(__file__).parent)
             repl_env = rep.init_repl_env(argv=[])
             repl_env.inject_native(**INJECTIONS[test_basename])
             with self.subTest(test_file=test_basename):
                 self.run_tests(
                     test_file,
                     functools.partial(rep.rep, env=repl_env),
                 )
         finally:
             os.chdir(cwd)
Beispiel #4
0
    def run_mal_in_mal(self, test_files, excludes=None):
        for test_file in test_files:
            test_basename = test_file.name
            if excludes and test_basename in excludes:
                continue
            cwd = Path.cwd()
            try:
                os.chdir(TEST_DIR)
                repl_env = rep.init_repl_env(argv=[str(test_file)])
                mal_script = TEST_DIR / ".." / "mal" / "stepA_mal.mal"
                rep.load_file(repl_env, mal_script)
                mal_function = repl_env.get("rep")

                def mal_rep(s):
                    return mal_function.call([MalString(s)]).native()

                with self.subTest(test_file=test_basename):
                    self.run_tests(test_file, mal_rep, hard=True)
            finally:
                os.chdir(cwd)
Beispiel #5
0
 def setUp(self) -> None:
     self._repl_env = step7_quote.init_repl_env()
Beispiel #6
0
 def setUp(self) -> None:
     self._repl_env = step5_tco.init_repl_env()
Beispiel #7
0
 def setUp(self) -> None:
     self._repl_env = step2_eval.init_repl_env()
Beispiel #8
0
 def setUp(self) -> None:
     self._repl_env = rep.init_repl_env()
Beispiel #9
0
 def setUp(self) -> None:
     self._repl_env = step8_macros.init_repl_env()
Beispiel #10
0
 def setUp(self) -> None:
     self._repl_env = step9_try.init_repl_env()
Beispiel #11
0
 def setUp(self) -> None:
     self._repl_env = step3_env.init_repl_env()
Beispiel #12
0
 def setUp(self) -> None:
     self._repl_env = rep.init_repl_env(execution_limit=ExecutionLimit(1))
Beispiel #13
0
 def setUp(self) -> None:
     self._repl_env = step4_if_fn_do.init_repl_env()
Beispiel #14
0
 def setUp(self) -> None:
     self._repl_env = step6_file.init_repl_env()