From eb8b17719d7781c011255b8292e9e3fc205612a4 Mon Sep 17 00:00:00 2001 From: Aaron Janse Date: Mon, 9 Mar 2020 13:28:44 -0700 Subject: [PATCH] fix id mode persistence after filter (fix #72) --- dots/states.py | 4 ++-- test/id_mode_persistence.dots | 7 +++++++ test/test_programs.py | 4 ++++ 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 test/id_mode_persistence.dots diff --git a/dots/states.py b/dots/states.py index b11bd80..c2267c4 100644 --- a/dots/states.py +++ b/dots/states.py @@ -222,12 +222,12 @@ def next(self, char): if self.parent.id == 0: return DeadState(self.parent) else: - return self + return TravelState(self.parent) elif char == ';': if self.parent.id == 1: return DeadState(self.parent) else: - return self + return TravelState(self.parent) else: return autodetect_next_state(self.parent, char) diff --git a/test/id_mode_persistence.dots b/test/id_mode_persistence.dots new file mode 100644 index 0000000..147d9c6 --- /dev/null +++ b/test/id_mode_persistence.dots @@ -0,0 +1,7 @@ + "Y"$\ + "N"$~-. +.-#8@1@:{%}--{=}-/ +.-#3-----/ | + | +.-#8@1@:-{%}--/ +.-#3------/ diff --git a/test/test_programs.py b/test/test_programs.py index fab40e0..0cf771b 100644 --- a/test/test_programs.py +++ b/test/test_programs.py @@ -128,6 +128,10 @@ def test_dots_filter_chars(): out = check_output('filter_chars', "END\n") assert out == [0, 0, 1, 1] +def test_dots_id_mode_persistence(): + out = check_output('id_mode_persistence') + assert out == map_add_newline("Y") + def test_dots_eof(): out = check_output('eof', "hi\n") assert len(out) == 5