summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2020-11-13 13:29:55 +0900
committerGitHub <noreply@github.com>2020-11-13 13:29:55 +0900
commit8f7ddba3cd343c2bada3c31c9660c63f0c6df114 (patch)
tree5faa4ec75f6ca586235e79bcdfd7f50a5ba53097
parentd76e5fc1d2cedeba29fe7a5292f5d451dea0da57 (diff)
parentdb91e90ac1375283f29e1f4a235cc7abb043c2f0 (diff)
downloadjson-8f7ddba3cd343c2bada3c31c9660c63f0c6df114.tar.gz
Merge pull request #450 from flori/backport-ruby-core
Backport ruby core
-rw-r--r--.travis.yml1
-rw-r--r--lib/json/add/complex.rb1
-rw-r--r--lib/json/add/rational.rb1
-rw-r--r--tests/json_common_interface_test.rb27
-rw-r--r--[-rwxr-xr-x]tests/json_generator_test.rb0
-rw-r--r--tests/json_parser_test.rb6
6 files changed, 10 insertions, 26 deletions
diff --git a/.travis.yml b/.travis.yml
index 78b19dd..0aaa2fb 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,7 +4,6 @@ language: ruby
# Specify which ruby versions you wish to run your tests on, each version will be used
rvm:
- - 2.0.0
- 2.1
- 2.2
- 2.3
diff --git a/lib/json/add/complex.rb b/lib/json/add/complex.rb
index 4d977e7..e63e29f 100644
--- a/lib/json/add/complex.rb
+++ b/lib/json/add/complex.rb
@@ -2,7 +2,6 @@
unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
require 'json'
end
-defined?(::Complex) or require 'complex'
class Complex
diff --git a/lib/json/add/rational.rb b/lib/json/add/rational.rb
index 6be4034..f776226 100644
--- a/lib/json/add/rational.rb
+++ b/lib/json/add/rational.rb
@@ -2,7 +2,6 @@
unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
require 'json'
end
-defined?(::Rational) or require 'rational'
class Rational
# Deserializes JSON string by converting numerator value <tt>n</tt>,
diff --git a/tests/json_common_interface_test.rb b/tests/json_common_interface_test.rb
index 4fdc2b1..9148b78 100644
--- a/tests/json_common_interface_test.rb
+++ b/tests/json_common_interface_test.rb
@@ -152,31 +152,18 @@ class JSONCommonInterfaceTest < Test::Unit::TestCase
temp_file_containing(@json) do |filespec|
parsed_object = JSON.public_send(method_name, filespec, symbolize_names: true)
key_classes = parsed_object.keys.map(&:class)
- assert_true key_classes.include?(Symbol) && (! key_classes.include?(String))
+ assert_include(key_classes, Symbol)
+ assert_not_include(key_classes, String)
end
end
- # Copied and slightly modified from https://github.com/keithrbennett/trick_bag
- # (https://github.com/keithrbennett/trick_bag/blob/master/lib/trick_bag/io/temp_files.rb).
- #
- # For the easy creation and deletion of a temp file populated with text,
- # wrapped around the code block you provide.
- #
- # @param text the text to write to the temporary file
- # @param file_prefix optional prefix for the temporary file's name
- # @yield filespec of the temporary file
def temp_file_containing(text, file_prefix = '')
raise "This method must be called with a code block." unless block_given?
- filespec = nil
- begin
- Tempfile.open(file_prefix) do |file|
- file << text
- filespec = file.path
- end
- yield(filespec)
- ensure
- File.delete(filespec) if filespec && File.exist?(filespec)
- end
+ Tempfile.create(file_prefix) do |file|
+ file << text
+ file.close
+ yield file.path
end
+ end
end
diff --git a/tests/json_generator_test.rb b/tests/json_generator_test.rb
index 2ecdc97..2ecdc97 100755..100644
--- a/tests/json_generator_test.rb
+++ b/tests/json_generator_test.rb
diff --git a/tests/json_parser_test.rb b/tests/json_parser_test.rb
index e29f3f1..dce693e 100644
--- a/tests/json_parser_test.rb
+++ b/tests/json_parser_test.rb
@@ -222,10 +222,10 @@ class JSONParserTest < Test::Unit::TestCase
assert_predicate parse('{}', :freeze => true), :frozen?
assert_predicate parse('[]', :freeze => true), :frozen?
assert_predicate parse('"foo"', :freeze => true), :frozen?
-
+
if string_deduplication_available?
- assert_same -'foo', parse('"foo"', :freeze => true)
- assert_same -'foo', parse('{"foo": 1}', :freeze => true).keys.first
+ assert_same(-'foo', parse('"foo"', :freeze => true))
+ assert_same(-'foo', parse('{"foo": 1}', :freeze => true).keys.first)
end
end