Runtime assertions for Ruby literal.fun
ruby
5
fork

Configure Feed

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

Constraints with no allocations

+13 -2
+11 -2
lib/literal/types/constraint_type.rb
··· 10 10 def inspect = "_Constraint(#{inspect_constraints})" 11 11 12 12 def ===(value) 13 - @object_constraints.all? { |t| t === value } && 14 - @property_constraints.all? { |a, t| t === value.public_send(a) } 13 + i, len = 0, @object_constraints.size 14 + while i < len 15 + return false unless @object_constraints[i] === value 16 + i += 1 17 + end 18 + 19 + @property_constraints.each do |a, t| 20 + return false unless t === value.public_send(a) 21 + end 22 + 23 + true 15 24 end 16 25 17 26 private
+2
test/allocations_test.rb
··· 52 52 53 53 assert_allocations(_Hash(String, Integer), { "a" => 1, "b" => 2 }) => 0 54 54 55 + assert_allocations(_Integer(18..), 18) => 0 56 + 55 57 assert_allocations(_JSONData, { "a" => 1, "b" => [true, false, 0, 1.23, nil, { "a" => 1 }] }) => 0 56 58 57 59 assert_allocations(_Map(name: String, age: Integer), { name: "Joel", age: 30 }) => 0