Pass the called keyword arguments if keyword_init

This commit is contained in:
Nobuyoshi Nakada 2019-10-21 12:20:19 +09:00
parent 215e4b8721
commit 431132f037
Notes: git 2019-10-21 15:30:27 +09:00
2 changed files with 19 additions and 6 deletions

View file

@ -112,6 +112,10 @@ module TestStruct
assert_equal @Struct::KeywordInitTrue.new(a: 1, b: 2).values, @Struct::KeywordInitFalse.new(1, 2).values
assert_equal "#{@Struct}::KeywordInitFalse", @Struct::KeywordInitFalse.inspect
assert_equal "#{@Struct}::KeywordInitTrue(keyword_init: true)", @Struct::KeywordInitTrue.inspect
k = Class.new(@Struct::KeywordInitFalse) {def initialize(**) end}
assert_warn(/The last argument is used as the keyword parameter/) {k.new(a: 1, b: 2)}
k = Class.new(@Struct::KeywordInitTrue) {def initialize(**) end}
assert_warn('') {k.new(a: 1, b: 2)}
@Struct.instance_eval do
remove_const(:KeywordInitTrue)