From d1b6ff42fa0c7345713ec5e40c9cd782dac88948 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 26 Jun 2023 13:49:02 +0900 Subject: [PATCH] Add the chopsticks code at RubyKaigi2023 --- test/test_trick.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/test_trick.rb b/test/test_trick.rb index 201dd50b9ba567..f0e7eb23b7c26c 100644 --- a/test/test_trick.rb +++ b/test/test_trick.rb @@ -214,6 +214,30 @@ def test_03_mame end end +class TestRubyKaigi2023🥢 < Test::Unit::TestCase + CHOPSTICKS = [<<~'0', <<~'1'] # by mame + BEGIN{q=:Ruby};p||=:Enjoy;END{puts p,q||2023} + 0 + q=print(q||"/:|}\n")||p&&:@Matsumoto;p=:Kaigi + 1 + + def test_chopsticks_0 + assert_in_out_err([], CHOPSTICKS[0], %w[Enjoy Ruby]) + end + + def test_chopsticks_1 + assert_in_out_err([], CHOPSTICKS[1], %w[/:|}]) + end + + def test_chopsticks_0_1 + assert_in_out_err([], "#{CHOPSTICKS[0]}\n#{CHOPSTICKS[1]}", %w[RubyKaigi @Matsumoto]) + end + + def test_chopsticks_1_0 + assert_in_out_err([], "#{CHOPSTICKS[1]}\n#{CHOPSTICKS[0]}", %w[RubyKaigi 2023]) + end +end + # https://github.com/mame/all-ruby-quine class TestAllRubyQuine < Test::Unit::TestCase def test_all_ruby_quine