mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
{ext,test}/ripper: Specify frozen_string_literal: true.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
cd6d919373
commit
e3300dce82
17 changed files with 28 additions and 27 deletions
|
@ -1,5 +1,5 @@
|
||||||
#!ruby -s
|
#!ruby -s
|
||||||
# frozen_string_literal: false
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'mkmf'
|
require 'mkmf'
|
||||||
require 'rbconfig'
|
require 'rbconfig'
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# frozen_string_literal: false
|
# frozen_string_literal: true
|
||||||
require 'ripper/core'
|
require 'ripper/core'
|
||||||
require 'ripper/lexer'
|
require 'ripper/lexer'
|
||||||
require 'ripper/filter'
|
require 'ripper/filter'
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# frozen_string_literal: false
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# $Id$
|
# $Id$
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# frozen_string_literal: false
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# $Id$
|
# $Id$
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# frozen_string_literal: false
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# $Id$
|
# $Id$
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# frozen_string_literal: false
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# $Id$
|
# $Id$
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# frozen_string_literal: false
|
# frozen_string_literal: true
|
||||||
off = true
|
off = true
|
||||||
ARGF.each do |line|
|
ARGF.each do |line|
|
||||||
case line
|
case line
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# frozen_string_literal: false
|
# frozen_string_literal: true
|
||||||
# $Id$
|
# $Id$
|
||||||
|
|
||||||
require 'optparse'
|
require 'optparse'
|
||||||
|
@ -68,7 +68,7 @@ def usage(msg)
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_eventids1(ids)
|
def generate_eventids1(ids)
|
||||||
buf = ""
|
buf = "".dup
|
||||||
buf << %Q[static struct {\n]
|
buf << %Q[static struct {\n]
|
||||||
ids.each do |id, arity|
|
ids.each do |id, arity|
|
||||||
buf << %Q[ ID id_#{id};\n]
|
buf << %Q[ ID id_#{id};\n]
|
||||||
|
@ -101,7 +101,7 @@ def generate_eventids1(ids)
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_eventids2_table(ids)
|
def generate_eventids2_table(ids)
|
||||||
buf = ""
|
buf = "".dup
|
||||||
buf << %Q[static void\n]
|
buf << %Q[static void\n]
|
||||||
buf << %Q[ripper_init_eventids2_table(VALUE self)\n]
|
buf << %Q[ripper_init_eventids2_table(VALUE self)\n]
|
||||||
buf << %Q[{\n]
|
buf << %Q[{\n]
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# frozen_string_literal: false
|
# frozen_string_literal: true
|
||||||
# $Id$
|
# $Id$
|
||||||
|
|
||||||
require 'optparse'
|
require 'optparse'
|
||||||
|
@ -24,7 +24,7 @@ def main
|
||||||
unless ARGV.size == 1
|
unless ARGV.size == 1
|
||||||
abort "wrong number of arguments (#{ARGV.size} for 1)"
|
abort "wrong number of arguments (#{ARGV.size} for 1)"
|
||||||
end
|
end
|
||||||
out = ""
|
out = "".dup
|
||||||
File.open(ARGV[0]) {|f|
|
File.open(ARGV[0]) {|f|
|
||||||
prelude f, out
|
prelude f, out
|
||||||
grammar f, out
|
grammar f, out
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# frozen_string_literal: false
|
# frozen_string_literal: true
|
||||||
last_is_void = false
|
last_is_void = false
|
||||||
ARGF.each do |line|
|
ARGF.each do |line|
|
||||||
case line
|
case line
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# frozen_string_literal: false
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# dummyparser.rb
|
# dummyparser.rb
|
||||||
#
|
#
|
||||||
|
@ -186,7 +186,7 @@ class DummyParser < Ripper
|
||||||
end
|
end
|
||||||
|
|
||||||
def on_word_new
|
def on_word_new
|
||||||
""
|
"".dup
|
||||||
end
|
end
|
||||||
|
|
||||||
def on_word_add(word, w)
|
def on_word_add(word, w)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# frozen_string_literal: false
|
# frozen_string_literal: true
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
|
|
||||||
module TestRipper; end
|
module TestRipper; end
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# frozen_string_literal: false
|
# frozen_string_literal: true
|
||||||
begin
|
begin
|
||||||
require 'ripper'
|
require 'ripper'
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
begin
|
begin
|
||||||
require_relative 'dummyparser'
|
require_relative 'dummyparser'
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# frozen_string_literal: false
|
# frozen_string_literal: true
|
||||||
begin
|
begin
|
||||||
require 'ripper'
|
require 'ripper'
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
|
@ -37,7 +37,7 @@ class TestRipper::Ripper < Test::Unit::TestCase
|
||||||
|
|
||||||
def test_filename
|
def test_filename
|
||||||
assert_equal '(ripper)', @ripper.filename
|
assert_equal '(ripper)', @ripper.filename
|
||||||
filename = "ripper"
|
filename = "ripper".dup
|
||||||
ripper = Ripper.new("", filename)
|
ripper = Ripper.new("", filename)
|
||||||
filename.clear
|
filename.clear
|
||||||
assert_equal "ripper", ripper.filename
|
assert_equal "ripper", ripper.filename
|
||||||
|
@ -63,11 +63,11 @@ class TestRipper::Ripper < Test::Unit::TestCase
|
||||||
|
|
||||||
def test_regexp_with_option
|
def test_regexp_with_option
|
||||||
bug11932 = '[ruby-core:72638] [Bug #11932]'
|
bug11932 = '[ruby-core:72638] [Bug #11932]'
|
||||||
src = '/[\xC0-\xF0]/u'.force_encoding(Encoding::UTF_8)
|
src = '/[\xC0-\xF0]/u'.dup.force_encoding(Encoding::UTF_8)
|
||||||
ripper = Ripper.new(src)
|
ripper = Ripper.new(src)
|
||||||
ripper.parse
|
ripper.parse
|
||||||
assert_predicate(ripper, :error?)
|
assert_predicate(ripper, :error?)
|
||||||
src = '/[\xC0-\xF0]/n'.force_encoding(Encoding::UTF_8)
|
src = '/[\xC0-\xF0]/n'.dup.force_encoding(Encoding::UTF_8)
|
||||||
ripper = Ripper.new(src)
|
ripper = Ripper.new(src)
|
||||||
ripper.parse
|
ripper.parse
|
||||||
assert_not_predicate(ripper, :error?, bug11932)
|
assert_not_predicate(ripper, :error?, bug11932)
|
||||||
|
@ -101,11 +101,11 @@ class TestRipper::Ripper < Test::Unit::TestCase
|
||||||
|
|
||||||
# https://bugs.jruby.org/4176
|
# https://bugs.jruby.org/4176
|
||||||
def test_dedent_string
|
def test_dedent_string
|
||||||
col = Ripper.dedent_string ' hello', 0
|
col = Ripper.dedent_string ' hello'.dup, 0
|
||||||
assert_equal 0, col
|
assert_equal 0, col
|
||||||
col = Ripper.dedent_string ' hello', 2
|
col = Ripper.dedent_string ' hello'.dup, 2
|
||||||
assert_equal 2, col
|
assert_equal 2, col
|
||||||
col = Ripper.dedent_string ' hello', 4
|
col = Ripper.dedent_string ' hello'.dup, 4
|
||||||
assert_equal 2, col
|
assert_equal 2, col
|
||||||
|
|
||||||
# lexing a squiggly heredoc triggers Ripper#dedent_string use
|
# lexing a squiggly heredoc triggers Ripper#dedent_string use
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# frozen_string_literal: false
|
# frozen_string_literal: true
|
||||||
#
|
#
|
||||||
# test_scanner_events.rb
|
# test_scanner_events.rb
|
||||||
#
|
#
|
||||||
|
@ -134,7 +134,7 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_location(src)
|
def assert_location(src)
|
||||||
buf = ''
|
buf = ''.dup
|
||||||
Ripper.lex(src).each do |pos, type, tok|
|
Ripper.lex(src).each do |pos, type, tok|
|
||||||
line, col = *pos
|
line, col = *pos
|
||||||
assert_equal buf.count("\n") + 1, line,
|
assert_equal buf.count("\n") + 1, line,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# frozen_string_literal: false
|
# frozen_string_literal: true
|
||||||
begin
|
begin
|
||||||
require 'ripper'
|
require 'ripper'
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
|
|
Loading…
Add table
Reference in a new issue