Skip to content

Commit

Permalink
Merge pull request #133 from emancu/add_ruby_3.1
Browse files Browse the repository at this point in the history
Add Ruby 3.1 and fix linter
  • Loading branch information
emancu authored Jan 9, 2022
2 parents 5b98e32 + 480e55f commit 04898eb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby-version: ['2.5', '2.6', '2.7', '3.0', truffleruby-head]
ruby-version: ['2.5', '2.6', '2.7', '3.0', '3.1', truffleruby-head]

steps:
- uses: actions/checkout@v2
Expand All @@ -42,7 +42,7 @@ jobs:
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
ruby-version: '2.5'
bundler-cache: true # runs 'bundle install' and caches installed gems automatically

- name: Run standardrb
Expand Down
28 changes: 14 additions & 14 deletions test/grammar_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,24 @@ def test_table
indentation_alternatives_for("[akey]") do |str|
match = TomlRB::Document.parse(str, root: :table)
assert_equal(TomlRB::Table, match.value.class)
assert_equal(["akey"], match.value.instance_variable_get("@dotted_keys"))
assert_equal(["akey"], match.value.instance_variable_get(:@dotted_keys))
end

match = TomlRB::Document.parse("[owner.emancu]", root: :table)
assert_equal(%w[owner emancu],
match.value.instance_variable_get("@dotted_keys"))
match.value.instance_variable_get(:@dotted_keys))

match = TomlRB::Document.parse('["owner.emancu"]', root: :table)
assert_equal(%w[owner.emancu],
match.value.instance_variable_get("@dotted_keys"))
match.value.instance_variable_get(:@dotted_keys))

match = TomlRB::Document.parse('["first key"."second key"]', root: :table)
assert_equal(["first key", "second key"],
match.value.instance_variable_get("@dotted_keys"))
match.value.instance_variable_get(:@dotted_keys))

match = TomlRB::Document.parse("[ owner . emancu ]", root: :table)
assert_equal(%w[owner emancu],
match.value.instance_variable_get("@dotted_keys"))
match.value.instance_variable_get(:@dotted_keys))

assert_raises Citrus::ParseError do
TomlRB::Document.parse("[ owner emancu ]", root: :table)
Expand All @@ -48,19 +48,19 @@ def test_keyvalue
assert_equal(TomlRB::Keyvalue, match.value.class)

keyvalue = match.value
assert_equal("key", keyvalue.instance_variable_get("@dotted_keys").first)
assert_equal("value", keyvalue.instance_variable_get("@value"))
assert_equal("key", keyvalue.instance_variable_get(:@dotted_keys).first)
assert_equal("value", keyvalue.instance_variable_get(:@value))
end

indentation_alternatives_for('key1."key2".key3 = "value"') do |str|
match = TomlRB::Document.parse(str, root: :keyvalue)
assert_equal(TomlRB::Keyvalue, match.value.class)

keyvalue = match.value
assert_equal("key1", keyvalue.instance_variable_get("@dotted_keys")[0])
assert_equal("key2", keyvalue.instance_variable_get("@dotted_keys")[1])
assert_equal("key3", keyvalue.instance_variable_get("@dotted_keys")[2])
assert_equal("value", keyvalue.instance_variable_get("@value"))
assert_equal("key1", keyvalue.instance_variable_get(:@dotted_keys)[0])
assert_equal("key2", keyvalue.instance_variable_get(:@dotted_keys)[1])
assert_equal("key3", keyvalue.instance_variable_get(:@dotted_keys)[2])
assert_equal("value", keyvalue.instance_variable_get(:@value))
end
end

Expand Down Expand Up @@ -207,11 +207,11 @@ def test_signed_numbers
def test_expressions_with_comments
match = TomlRB::Document.parse("[shouldwork] # with comment", root: :table)
assert_equal(["shouldwork"],
match.value.instance_variable_get("@dotted_keys"))
match.value.instance_variable_get(:@dotted_keys))

match = TomlRB::Document.parse("works = true # with comment", root: :keyvalue).value
assert_equal("works", match.instance_variable_get("@dotted_keys").first)
assert_equal(true, match.instance_variable_get("@value"))
assert_equal("works", match.instance_variable_get(:@dotted_keys).first)
assert_equal(true, match.instance_variable_get(:@value))
end

def test_array
Expand Down

0 comments on commit 04898eb

Please sign in to comment.