builder-7000
builder-7000

Reputation: 7627

Ruby Range test case SyntaxError

I'm running Ruby's Range test case but got an error in the line:

assert_equal([*"a".."z", "aa"], ("a"..).take(27))

The error message is:

test/ruby/test_range.rb:38: syntax error, unexpected ')'
...qual([*"a".."z", "aa"], ("a"..).take(27))
...                              ^

I also tried ('a'..) in irb and got a SyntaxError:

irb> ('a'..)
Traceback (most recent call last):
        1: from /home/sergioro/.rvm/rubies/ruby-2.5.3/bin/irb:11:in `<main>'
SyntaxError ((irb):9: syntax error, unexpected ')')
('a'..)

My question is what is ('a'..)? This syntax is used several times in the test case but it is not described in Range's documentation.


Update:

Installing Ruby version 2.6.4 solved the error for ('a'..). But there is an error if the endless range is on the left, like in test_range.rb:536:

assert_operator(..'Z', :===, 'ANA')

The error is:

test_range.rb:536: syntax error, unexpected .., expecting ')'
    assert_operator(..'Z', :===, 'ANA')

Upvotes: 0

Views: 66

Answers (1)

mrzasa
mrzasa

Reputation: 23317

('a'..) is endless range introduced in ruby 2.6. You need to install Ruby 2.6 and run this test on ruby 2.6.

Upvotes: 1

Related Questions