[前][次][番号順一覧][スレッド一覧]

ruby-changes:67994

From: Hiroshi <ko1@a...>
Date: Wed, 15 Sep 2021 08:53:46 +0900 (JST)
Subject: [ruby-changes:67994] f650ca7568 (master): [ruby/racc] Rename helper to case

https://git.ruby-lang.org/ruby.git/commit/?id=f650ca7568

From f650ca7568d076f6e7afb32886abfcf85b17275d Mon Sep 17 00:00:00 2001
From: Hiroshi SHIBATA <hsbt@r...>
Date: Tue, 14 Sep 2021 21:15:33 +0900
Subject: [ruby/racc] Rename helper to case

---
 test/racc/assets/mof.y                |   2 +-
 test/racc/case.rb                     | 110 ++++++++++++++++++++++++++++++++++
 test/racc/helper.rb                   | 110 ----------------------------------
 test/racc/regress/mof                 |   2 +-
 test/racc/test_chk_y.rb               |   2 +-
 test/racc/test_grammar_file_parser.rb |   2 +-
 test/racc/test_racc_command.rb        |   2 +-
 test/racc/test_scan_y.rb              |   2 +-
 8 files changed, 116 insertions(+), 116 deletions(-)
 create mode 100644 test/racc/case.rb
 delete mode 100644 test/racc/helper.rb

diff --git a/test/racc/assets/mof.y b/test/racc/assets/mof.y
index da31729..b241f74 100644
--- a/test/racc/assets/mof.y
+++ b/test/racc/assets/mof.y
@@ -565,7 +565,7 @@ require 'rubygems' https://github.com/ruby/ruby/blob/trunk/test/racc/assets/mof.y#L565
 require 'cim'
 require File.join(File.dirname(__FILE__), 'result')
 require File.join(File.dirname(__FILE__), 'scanner')
-require File.join(File.dirname(__FILE__), 'helper')
+require File.join(File.dirname(__FILE__), 'case')
 
 ---- inner ----
 
diff --git a/test/racc/case.rb b/test/racc/case.rb
new file mode 100644
index 0000000..d5f9dad
--- /dev/null
+++ b/test/racc/case.rb
@@ -0,0 +1,110 @@ https://github.com/ruby/ruby/blob/trunk/test/racc/case.rb#L1
+verbose = $VERBOSE
+$VERBOSE = true
+begin
+
+require 'test/unit'
+require 'racc/static'
+require 'fileutils'
+require 'tempfile'
+require 'timeout'
+
+module Racc
+  class TestCase < Test::Unit::TestCase
+    PROJECT_DIR = File.expand_path(File.join(File.dirname(__FILE__), '..'))
+
+    test_dir = File.join(PROJECT_DIR, 'test')
+    test_dir = File.join(PROJECT_DIR, 'racc') unless File.exist?(test_dir)
+    TEST_DIR = test_dir
+    racc = File.join(PROJECT_DIR, 'bin', 'racc')
+    racc = File.join(PROJECT_DIR, '..', 'libexec', 'racc') unless File.exist?(racc)
+    RACC = racc
+    ASSET_DIR = File.join(TEST_DIR, 'assets') # test grammars
+    REGRESS_DIR  = File.join(TEST_DIR, 'regress') # known-good generated outputs
+
+    INC = [
+      File.join(PROJECT_DIR, 'lib'),
+      File.join(PROJECT_DIR, 'ext'),
+    ].join(':')
+
+    def setup
+      @TEMP_DIR = Dir.mktmpdir("racc")
+      @OUT_DIR  = File.join(@TEMP_DIR, 'out')
+      @TAB_DIR  = File.join(@TEMP_DIR, 'tab') # generated parsers go here
+      @LOG_DIR  = File.join(@TEMP_DIR, 'log')
+      @ERR_DIR  = File.join(@TEMP_DIR, 'err')
+      FileUtils.mkdir_p([@OUT_DIR, @TAB_DIR, @LOG_DIR, @ERR_DIR])
+      FileUtils.cp File.join(TEST_DIR, "src.intp"), @TEMP_DIR
+    end
+
+    def teardown
+      FileUtils.rm_f(File.join(@TEMP_DIR, "src.intp"))
+      FileUtils.rm_rf([@OUT_DIR, @TAB_DIR, @LOG_DIR, @ERR_DIR, @TEMP_DIR])
+    end
+
+    def assert_compile(asset, args = [], **opt)
+      file = File.basename(asset, '.y')
+      args = ([args].flatten) + [
+        "#{ASSET_DIR}/#{file}.y",
+        '-Do',
+        "-O#{@OUT_DIR}/#{file}",
+        "-o#{@TAB_DIR}/#{file}",
+      ]
+      racc(*args, **opt)
+    end
+
+    def assert_debugfile(asset, ok)
+      file = File.basename(asset, '.y')
+      Dir.chdir(@LOG_DIR) do
+        File.foreach("#{file}.y") do |line|
+          line.strip!
+          case line
+          when /sr/ then assert_equal "sr#{ok[0]}", line
+          when /rr/ then assert_equal "rr#{ok[1]}", line
+          when /un/ then assert_equal "un#{ok[2]}", line
+          when /ur/ then assert_equal "ur#{ok[3]}", line
+          when /ex/ then assert_equal "ex#{ok[4]}", line
+          else
+            raise TestFailed, 'racc outputs unknown debug report???'
+          end
+        end
+      end
+    end
+
+    def assert_exec(asset)
+      lib_path = File.expand_path("../../lib", __FILE__)
+      file = File.basename(asset, '.y')
+      ruby "-I#{lib_path}", "#{@TAB_DIR}/#{file}"
+    end
+
+    def strip_version(source)
+      source.sub(/This file is automatically generated by Racc \d+\.\d+\.\d+/, '')
+    end
+
+    def assert_output_unchanged(asset)
+      file = File.basename(asset, '.y')
+
+      # Code to re-generate the expectation files
+      # File.write("#{REGRESS_DIR}/#{file}", File.read("#{@TAB_DIR}/#{file}"))
+
+      expected = File.read("#{REGRESS_DIR}/#{file}")
+      actual   = File.read("#{@TAB_DIR}/#{file}")
+      result   = (strip_version(expected) == strip_version(actual))
+
+      assert(result, "Output of test/assets/#{file}.y differed from " \
+        "expectation. Try compiling it and diff with test/regress/#{file}.")
+    end
+
+    def racc(*arg, **opt)
+      lib_path = File.expand_path("../../lib", __FILE__)
+      ruby "-I#{lib_path}", "-S", RACC, *arg, **opt
+    end
+
+    def ruby(*arg, **opt)
+      assert_ruby_status(["-C", @TEMP_DIR, *arg], **opt)
+    end
+  end
+end
+
+ensure
+$VERBOSE = verbose
+end
diff --git a/test/racc/helper.rb b/test/racc/helper.rb
deleted file mode 100644
index d5f9dad..0000000
--- a/test/racc/helper.rb
+++ /dev/null
@@ -1,110 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/test/racc/case.rb#L0
-verbose = $VERBOSE
-$VERBOSE = true
-begin
-
-require 'test/unit'
-require 'racc/static'
-require 'fileutils'
-require 'tempfile'
-require 'timeout'
-
-module Racc
-  class TestCase < Test::Unit::TestCase
-    PROJECT_DIR = File.expand_path(File.join(File.dirname(__FILE__), '..'))
-
-    test_dir = File.join(PROJECT_DIR, 'test')
-    test_dir = File.join(PROJECT_DIR, 'racc') unless File.exist?(test_dir)
-    TEST_DIR = test_dir
-    racc = File.join(PROJECT_DIR, 'bin', 'racc')
-    racc = File.join(PROJECT_DIR, '..', 'libexec', 'racc') unless File.exist?(racc)
-    RACC = racc
-    ASSET_DIR = File.join(TEST_DIR, 'assets') # test grammars
-    REGRESS_DIR  = File.join(TEST_DIR, 'regress') # known-good generated outputs
-
-    INC = [
-      File.join(PROJECT_DIR, 'lib'),
-      File.join(PROJECT_DIR, 'ext'),
-    ].join(':')
-
-    def setup
-      @TEMP_DIR = Dir.mktmpdir("racc")
-      @OUT_DIR  = File.join(@TEMP_DIR, 'out')
-      @TAB_DIR  = File.join(@TEMP_DIR, 'tab') # generated parsers go here
-      @LOG_DIR  = File.join(@TEMP_DIR, 'log')
-      @ERR_DIR  = File.join(@TEMP_DIR, 'err')
-      FileUtils.mkdir_p([@OUT_DIR, @TAB_DIR, @LOG_DIR, @ERR_DIR])
-      FileUtils.cp File.join(TEST_DIR, "src.intp"), @TEMP_DIR
-    end
-
-    def teardown
-      FileUtils.rm_f(File.join(@TEMP_DIR, "src.intp"))
-      FileUtils.rm_rf([@OUT_DIR, @TAB_DIR, @LOG_DIR, @ERR_DIR, @TEMP_DIR])
-    end
-
-    def assert_compile(asset, args = [], **opt)
-      file = File.basename(asset, '.y')
-      args = ([args].flatten) + [
-        "#{ASSET_DIR}/#{file}.y",
-        '-Do',
-        "-O#{@OUT_DIR}/#{file}",
-        "-o#{@TAB_DIR}/#{file}",
-      ]
-      racc(*args, **opt)
-    end
-
-    def assert_debugfile(asset, ok)
-      file = File.basename(asset, '.y')
-      Dir.chdir(@LOG_DIR) do
-        File.foreach("#{file}.y") do |line|
-          line.strip!
-          case line
-          when /sr/ then assert_equal "sr#{ok[0]}", line
-          when /rr/ then assert_equal "rr#{ok[1]}", line
-          when /un/ then assert_equal "un#{ok[2]}", line
-          when /ur/ then assert_equal "ur#{ok[3]}", line
-          when /ex/ then assert_equal "ex#{ok[4]}", line
-          else
-            raise TestFailed, 'racc outputs unknown debug report???'
-          end
-        end
-      end
-    end
-
-    def assert_exec(asset)
-      lib_path = File.expand_path("../../lib", __FILE__)
-      file = File.basename(asset, '.y')
-      ruby "-I#{lib_path}", "#{@TAB_DIR}/#{file}"
-    end
-
-    def strip_version(source)
-      source.sub(/This file is automatically generated by Racc \d+\.\d+\.\d+/, '')
-    end
-
-    def assert_output_unchanged(asset)
-      file = File.basename(asset, '.y')
-
-      # Code to re-generate the expectation files
-      # File.write("#{REGRESS_DIR}/#{file}", File.read("#{@TAB_DIR}/#{file}"))
-
-      expected = File.read("#{REGRESS_DIR}/#{file}")
-      actual   = File.read("#{@TAB_DIR}/#{file}")
-      result   = (strip_version(expected) == strip_version(actual))
-
-      assert(result, "Output of test/assets/#{file}.y differed from " \
-        "expectation. Try compiling it and diff with test/regress/#{file}.")
-    end
-
-    def racc(*arg, **opt)
-      lib_path = File.expand_path("../../lib", __FILE__)
-      ruby "-I#{lib_path}", "-S", RACC, *arg, **opt
-    end
-
-    def ruby(*arg, **opt)
-      assert_ruby_status(["-C", @TEMP_DIR, *arg], **opt)
-    end
-  end
-end
-
-ensure
-$VERBOSE = verbose
-end
diff --git a/test/racc/regress/mof b/test/racc/regress/mof
index 8366047..614bcc0 100644
--- a/test/racc/regress/mof
+++ b/test/racc/regress/mof
@@ -14,7 +14,7 @@ require 'rubygems' https://github.com/ruby/ruby/blob/trunk/test/racc/regress/mof#L14
 require 'cim'
 require File.join(File.dirname(__FILE__), 'result')
 require File.join(File.dirname(__FILE__), 'scanner')
-require File.join(File.dirname(__FILE__), 'helper')
+require File.join(File.dirname(__FILE__), 'case')
 
 module MOF
   class Parser < Racc::Parser
diff --git a/test/racc/test_chk_y.rb b/test/racc/test_chk_y.rb
index bb8b6b4..dfe5b09 100644
--- a/test/racc/test_chk_y.rb
+++ b/test/racc/test_chk_y.rb
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/test/racc/test_chk_y.rb#L1
-require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
+require File.expand_path(File.join(File.dirname(__FILE__), 'case'))
 
 module Racc
   class TestChkY < TestCase
diff --git a/test/racc/test_grammar_file_parser.rb b/test/racc/test_grammar_file_parser.rb
index b187bdc..ddfc017 100644
--- a/test/racc/test_grammar_file_parser.rb
+++ b/test/racc/test_grammar_file_parser.rb
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/test/racc/test_grammar_file_parser.rb#L1
-require File.expand_path(File.join(File.dirname(__FILE__), 'helper (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]