-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
79e3742
commit bceb7ff
Showing
13 changed files
with
216 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
fails:The for expression returns expr | ||
fails:The for expression allows 'break' to have an argument which becomes the value of the for expression |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,3 @@ | ||
fails:Hash literal {} should return an empty hash | ||
fails:Hash literal {} should return a new hash populated with the given elements | ||
fails:Hash literal freezes string keys on initialization | ||
fails:Hash literal checks duplicated keys on initialization | ||
fails:Hash literal accepts a hanging comma | ||
fails:Hash literal recognizes '=' at the end of the key | ||
fails:Hash literal constructs a new hash with the given elements | ||
fails:Hash literal ignores a hanging comma | ||
fails:Hash literal accepts mixed 'key: value' and 'key => value' syntax | ||
fails:Hash literal accepts mixed 'key: value', 'key => value' and '"key"': value' syntax | ||
fails:Hash literal expands an '**{}' element into the containing Hash literal initialization | ||
fails:Hash literal expands an '**obj' element into the containing Hash literal initialization | ||
fails:Hash literal expands a BasicObject using ** into the containing Hash literal initialization | ||
fails:Hash literal expands an '**{}' element with the last key/value pair taking precedence | ||
fails:Hash literal merges multiple nested '**obj' in Hash literals | ||
fails:Hash literal calls #to_hash to expand an '**obj' element | ||
fails:Hash literal raises a TypeError if any splatted elements keys are not symbols | ||
fails:Hash literal raises a TypeError if #to_hash does not return a Hash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
fails:A lambda literal -> () { } returns a lambda | ||
fails:A lambda literal -> () { } assigns variables from parameters for definition '@a = -> (a={}) { a }' | ||
fails:A lambda literal -> () { } assigns variables from parameters for definition '@a = -> (**) { }' | ||
fails:A lambda literal -> () { } assigns variables from parameters for definition '@a = -> (**k) { k }' | ||
fails:A lambda literal -> () { } assigns variables from parameters for definition '@a = -> (*, **k) { k }' | ||
fails:A lambda literal -> () { } assigns variables from parameters for definition '@a = -> (&b) { b }' | ||
fails:A lambda literal -> () { } assigns variables from parameters for definition '@a = -> (*, &b) { b }' | ||
fails:"A lambda literal -> () { } assigns variables from parameters for definition \n @a = -> (a, b=1, *c, (*d, (e)), f: 2, g:, h:, **k, &l) do\n [a, b, c, d, e, f, g, h, k, l]\n end" | ||
fails:"A lambda literal -> () { } assigns variables from parameters for definition \n @a = -> a, b=1, *c, d, e:, f: 2, g:, **k, &l do\n [a, b, c, d, e, f, g, k, l]\n end" | ||
fails:A lambda expression 'lambda { ... }' returns a lambda | ||
fails:A lambda expression 'lambda { ... }' with an implicit block can be created | ||
fails:"A lambda expression 'lambda { ... }' assigns variables from parameters for definition \n def m(*a) yield(*a) end\n @a = lambda { |a| a }" | ||
fails:A lambda expression 'lambda { ... }' assigns variables from parameters for definition '@a = lambda { |a, | a }' | ||
fails:"A lambda expression 'lambda { ... }' assigns variables from parameters for definition \n def m(a) yield a end\n def m2() yield end\n @a = lambda { |a, | a }" | ||
fails:A lambda expression 'lambda { ... }' assigns variables from parameters for definition '@a = lambda { |a={}| a }' | ||
fails:A lambda expression 'lambda { ... }' assigns variables from parameters for definition '@a = lambda { |**| }' | ||
fails:A lambda expression 'lambda { ... }' assigns variables from parameters for definition '@a = lambda { |**k| k }' | ||
fails:A lambda expression 'lambda { ... }' assigns variables from parameters for definition '@a = lambda { |*, **k| k }' | ||
fails:A lambda expression 'lambda { ... }' assigns variables from parameters for definition '@a = lambda { |&b| b }' | ||
fails:A lambda expression 'lambda { ... }' assigns variables from parameters for definition '@a = lambda { |*, &b| b }' | ||
fails:"A lambda expression 'lambda { ... }' assigns variables from parameters for definition \n @a = lambda do |a, b=1, *c, (*d, (e)), f: 2, g:, h:, **k, &l|\n [a, b, c, d, e, f, g, h, k, l]\n end" | ||
fails:"A lambda expression 'lambda { ... }' assigns variables from parameters for definition \n @a = lambda do |a, b=1, *c, d, e:, f: 2, g:, **k, &l|\n [a, b, c, d, e, f, g, k, l]\n end" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,2 @@ | ||
fails:A Proc taking zero arguments raises an ArgumentError if a value is passed | ||
fails:A Proc taking || arguments raises an ArgumentError if a value is passed | ||
fails:A Proc taking |a, *b| arguments does not destructure a single Array value yielded | ||
fails:A Proc taking |a, | arguments raises an ArgumentError when passed more than one value | ||
fails:A Proc taking |a, | arguments does not destructure when passed a single Array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,2 @@ | ||
fails:Invoking a method with only mandatory arguments raises ArgumentError if the methods arity doesn't match | ||
fails:Invoking a method with optional arguments raises ArgumentError if extra arguments are passed | ||
fails:Invoking a method with mandatory and optional arguments raises an ArgumentError if too many values are passed | ||
fails:Invoking a private getter method does not permit self as a receiver | ||
fails:Invoking a method accepts final explicit literal Hash arguments after the splat | ||
fails:Invoking a method accepts final implicit literal Hash arguments after the splat | ||
fails:Invoking a method accepts final Hash arguments after the splat | ||
fails:Invoking a method accepts mandatory and explicit literal Hash arguments after the splat | ||
fails:Invoking a method accepts mandatory and implicit literal Hash arguments after the splat | ||
fails:Invoking a method accepts mandatory and Hash arguments after the splat | ||
fails:Invoking a method expands the Array elements from the splat after executing the arguments and block if no other arguments follow the splat | ||
fails:Invoking a method with optional argument(s), expands an array to arguments grouped in parentheses | ||
fails:Invoking a method with required args after the rest arguments binds the required arguments first | ||
fails:Invoking a method with mandatory arguments after optional arguments binds the required arguments first |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
class CategorizedArguments | ||
attr_reader :req, :opt, :rest, :post, :kw, :kwrest, :block | ||
|
||
def initialize(arg_names, args_info) | ||
@req = [] | ||
@opt = [] | ||
@rest = nil | ||
@post = [] | ||
@kw = [] | ||
@kwrest = [] | ||
@block = nil | ||
|
||
parse!(arg_names.dup, args_info.dup) | ||
end | ||
|
||
KwReq = Struct.new(:name, keyword_init: true) | ||
InlineKwOpt = Struct.new(:name, :default, keyword_init: true) | ||
DynamicKwOpt = Struct.new(:name, keyword_init: true) | ||
|
||
def parse!(arg_names, args_info) | ||
(args_info[:lead_num] || 0).times do | ||
req << take_arg(arg_names) | ||
end | ||
|
||
opt_info = args_info[:opt].dup || [] | ||
opt_info.shift | ||
opt_info.each do |label| | ||
opt << [take_arg(arg_names), label] | ||
end | ||
|
||
if args_info[:rest_start] | ||
@rest = take_arg(arg_names) | ||
end | ||
|
||
(args_info[:post_num] || 0).times do | ||
post << take_arg(arg_names) | ||
end | ||
|
||
(args_info[:keyword] || []).each do |kwarg| | ||
arg = | ||
case kwarg | ||
when Symbol | ||
KwReq.new(name: kwarg) | ||
when Array | ||
if kwarg.length == 2 | ||
# inline default | ||
InlineKwOpt.new(name: kwarg[0], default: kwarg[1]) | ||
else | ||
# complex default, set in the iseq | ||
DynamicKwOpt.new(name: kwarg[0]) | ||
end | ||
else | ||
raise VM::InternalError, "Unknown kwarg #{kwarg}" | ||
end | ||
|
||
arg_names.delete(arg.name) | ||
kw << arg | ||
end | ||
|
||
if args_info[:kwrest] | ||
kwrest << take_arg(arg_names) << take_arg(arg_names) | ||
end | ||
|
||
if args_info[:block_start] | ||
@block = take_arg(arg_names) | ||
end | ||
end | ||
|
||
def take_arg(arg_names) | ||
arg_name_or_idx = arg_names.shift | ||
|
||
if arg_name_or_idx.is_a?(Integer) | ||
arg_name_or_idx += 1 | ||
end | ||
|
||
arg_name_or_idx | ||
end | ||
end |
Oops, something went wrong.