Runtime assertions for Ruby literal.fun
ruby
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

Flatten constraints (#287)

When a constraint has only one argument, it can be flattened to that argument.

authored by

Joel Drapper and committed by
GitHub
1f2d3018 19a2b095

+6 -7
+6 -2
lib/literal/types.rb
··· 116 116 # ```ruby 117 117 # _Constraint(Array, size: 1..3) 118 118 # ``` 119 - def _Constraint(...) 120 - ConstraintType.new(...) 119 + def _Constraint(*a, **k) 120 + if a.length == 1 && k.length == 0 121 + a[0] 122 + else 123 + ConstraintType.new(*a, **k) 124 + end 121 125 end 122 126 123 127 # Nilable version of `_Constraint`
-5
test/types.test.rb
··· 179 179 180 180 refute _Constraint(Array, size: 1..2) >= _Constraint(Array, size: 1..3) 181 181 refute _Constraint(String, size: 4) >= _Constraint(String, size: 1) 182 - 183 - assert _Constraint(Enumerable) >= _Frozen(Array) 184 - assert _Constraint(Array) >= _Frozen(Array) 185 - 186 - assert _Constraint(Array) >= _Constraint(Array, Enumerable) 187 182 end 188 183 189 184 test "_Date" do