Skip to content

Commit

Permalink
Merge pull request #172 from tmm1/ruby-2.4.0
Browse files Browse the repository at this point in the history
Ruby 2.4's forwardable warns forwarding to private methods
  • Loading branch information
gfx committed Dec 28, 2016
2 parents a988d12 + 2bee83b commit 3aaabca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
8 changes: 1 addition & 7 deletions lib/pygments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def engine
end

def_delegators :engine,
# public
:formatters,
:lexers,
:lexers!,
Expand All @@ -23,11 +22,6 @@ def engine
:css,
:lexer_name_for,
:highlight,
# not public but documented
:start,
# only for testing
:size_check,
:get_fixed_bits_from_header,
:add_ids
:start
end
end
18 changes: 10 additions & 8 deletions test/test_pygments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
require File.join(File.dirname(__FILE__), '..', '/lib/pygments.rb')
ENV['mentos-test'] = "yes"


P = Pygments
PE = Pygments.engine

class PygmentsHighlightTest < Test::Unit::TestCase
RUBY_CODE = "#!/usr/bin/ruby\nputs 'foo'"
Expand Down Expand Up @@ -129,44 +131,44 @@ def test_highlight_on_multi_threads
# over the pipe I think it's necessary and informative.
class PygmentsValidityTest < Test::Unit::TestCase
def test_add_ids_with_padding
res = P.send(:add_ids, "herp derp baz boo foo", "ABCDEFGH")
res = PE.send(:add_ids, "herp derp baz boo foo", "ABCDEFGH")
assert_equal "ABCDEFGH herp derp baz boo foo ABCDEFGH", res
end

def test_add_ids_on_empty_string
res = P.send(:add_ids, "", "ABCDEFGH")
res = PE.send(:add_ids, "", "ABCDEFGH")
assert_equal "ABCDEFGH ABCDEFGH", res
end

def test_add_ids_with_unicode_data
res = P.send(:add_ids, "# ø ø ø", "ABCDEFGH")
res = PE.send(:add_ids, "# ø ø ø", "ABCDEFGH")
assert_equal "ABCDEFGH # ø ø ø ABCDEFGH", res
end

def test_add_ids_with_starting_slashes
res = P.send(:add_ids, '\\# ø ø ø..//', "ABCDEFGH")
res = PE.send(:add_ids, '\\# ø ø ø..//', "ABCDEFGH")
assert_equal "ABCDEFGH \\# ø ø ø..// ABCDEFGH", res
end

def test_get_fixed_bits_from_header
bits = P.send(:get_fixed_bits_from_header, '{"herp": "derp"}')
bits = PE.send(:get_fixed_bits_from_header, '{"herp": "derp"}')
assert_equal "00000000000000000000000000010000", bits
end

def test_get_fixed_bits_from_header_works_with_large_headers
bits = P.send(:get_fixed_bits_from_header, '{"herp": "derp"}' * 10000)
bits = PE.send(:get_fixed_bits_from_header, '{"herp": "derp"}' * 10000)
assert_equal "00000000000000100111000100000000", bits
end

def test_size_check
size = "00000000000000000000000000100110"
res = P.send(:size_check, size)
res = PE.send(:size_check, size)
assert_equal res, true
end

def test_size_check_bad
size = "some random thing"
res = P.send(:size_check, size)
res = PE.send(:size_check, size)
assert_equal res, false
end
end
Expand Down

0 comments on commit 3aaabca

Please sign in to comment.