Runtime assertions for Ruby literal.fun
ruby
5
fork

Configure Feed

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

Remove Literal::Brand

I think this is a very confusing tool because of interning.

-32
-22
lib/literal/brand.rb
··· 1 - # frozen_string_literal: true 2 - 3 - class Literal::Brand 4 - include Literal::Types 5 - 6 - def initialize(...) 7 - @type = _Constraint(...) 8 - @objects = ObjectSpace::WeakMap.new 9 - end 10 - 11 - def new(object) 12 - Literal.check(expected: @type, actual: object) 13 - @objects[object] = true 14 - object 15 - end 16 - 17 - alias_method :[], :new 18 - 19 - def ===(value) 20 - @objects.key?(value) 21 - end 22 - end
-10
test/brand.test.rb
··· 1 - # frozen_string_literal: true 2 - 3 - UserID = Literal::Brand(String) 4 - 5 - test "branded strings" do 6 - user_id = UserID.new("123") 7 - 8 - assert UserID === user_id 9 - assert_equal "123", user_id 10 - end