Skip to content

Commit 75a0a8f

Browse files
Test Ruby3's probably popular syntax elements
See https://www.ruby-lang.org/en/news/2020/12/25/ruby-3-0-0-released/, but excluding: - "in is changed …" because that's behaviour - "Find pattern …" because it's "experimental" - "Hash#except …" because the test runner doesn't care from where the student's code loads this method.
1 parent 6646b27 commit 75a0a8f

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# See section "Other Notable New Features"
2+
# in https://www.ruby-lang.org/en/news/2020/12/25/ruby-3-0-0-released/
3+
class Ruby3Syntax
4+
def self.rightward_assign
5+
'is fun' => exercism
6+
return exercism
7+
end
8+
9+
def self.endless_methods = 'are fun'
10+
end
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
require 'minitest/autorun'
2+
require_relative 'ruby_3_syntax'
3+
4+
# minimal set of:
5+
# Common test data version: 1.6.0 42b9d45
6+
class Ruby3SyntaxTest < Minitest::Test
7+
def test_rightward_assign
8+
assert_equal Ruby3Syntax.rightward_assign, 'is fun'
9+
end
10+
11+
def test_endless_method_def
12+
assert_equal Ruby3Syntax.endless_methods, 'are fun'
13+
end
14+
end

test/test_runner_test.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,29 @@ def test_pass
2929
)
3030
end
3131

32+
def test_pass_ruby_3
33+
assert_fixture(
34+
:pass_ruby_3_syntax,
35+
{
36+
version: 2,
37+
status: :pass,
38+
message: nil,
39+
tests: [
40+
{
41+
name: "Rightward assign",
42+
status: :pass,
43+
test_code: %(assert_equal Ruby3Syntax.rightward_assign, 'is fun')
44+
},
45+
{
46+
name: "Endless method def",
47+
status: :pass,
48+
test_code: %(assert_equal Ruby3Syntax.endless_methods, 'are fun')
49+
}
50+
]
51+
}
52+
)
53+
end
54+
3255
def test_fail
3356
assert_fixture(
3457
:fail, {

0 commit comments

Comments
 (0)