Skip to content

Commit

Permalink
Add tests and NEWS [Feature #18008]
Browse files Browse the repository at this point in the history
  • Loading branch information
nurse committed Jul 15, 2021
1 parent 1a63754 commit 835c63c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Expand Up @@ -96,6 +96,8 @@ Outstanding ones only.
You need to use a Hash literal to set a Hash to a first member.
[[Feature #16806]]

* StructClass#keyword_init? is added [[Feature #18008]]

* Queue

* Queue#initialize now accepts an Enumerable of initial values.
Expand Down
8 changes: 8 additions & 0 deletions test/ruby/test_struct.rb
Expand Up @@ -138,6 +138,14 @@ def c
assert_equal(3, struct.new(a: 1, b: 2).c)
end

def test_struct_keyword_init_p
struct = @Struct.new(:a, :b, keyword_init: true)
assert_equal(true, struct.keyword_init?)

struct = @Struct.new(:a, :b, keyword_init: false)
assert_equal(false, struct.keyword_init?)
end

def test_initialize
klass = @Struct.new(:a)
assert_raise(ArgumentError) { klass.new(1, 2) }
Expand Down

0 comments on commit 835c63c

Please sign in to comment.