{"atom":"regression/mu-roles-and-itemization","family":"regression","slug":"mu-roles-and-itemization","header":{"atom":"regression/mu-roles-and-itemization","kind":"whole-program — a minimal repro, not yet reduced to an atom","source":"curated"},"axes":null,"cols":null,"engines":["rakudo-2026.07","rakupp-3.14.0"],"kinds":["ref","pp"],"defFrom":"rakupp:t/regression/mu-roles-and-itemization.raku","counts":{"a":1,"f":0,"d":0,"c":0,"r":0,"n":0},"files":["atoms/regression/mu-roles-and-itemization.grid"],"records":[["0001","","# Regression: the Mu-level universal methods — role membership, `Mu.new`,\n# `.item`, `.Capture` — and the IterationEnd sentinel.\n#   * `.does` counts the ROLES in a built-in's ancestry (`Date.does(Dateish)`),\n#     while `.isa` is strict class inheritance and must reject them. The two were\n#     answering each other's results: .does(Dateish) was False and .isa(Dateish)\n#     True. Smartmatch agrees with .does, for an INSTANCE as well as a type.\n#   * `Mu.new` / `Any.new` had no implementation at all: an instance of the bare\n#     root type, defined and therefore truthy, gisting as `Mu.new`.\n#   * `.item` (and the `item(…)` sub) itemizes a Hash as well as an Array.\n#   * `$obj.Capture` is the object's public attributes as named arguments, read\n#     through their ACCESSORS — so a method that overrides an attribute wins.\n#   * IterationEnd is a sentinel, not a type object, so it gists bare.\n# Contract: exit 0 + last line PASS.\nmy @fail;\nsub check($got, $want, $what) { @fail.push(\"$what: got $got want $want\") unless $got eq $want }\n\n# .does counts roles, .isa does not\nmy $d = Date.new('2016-06-03');\ncheck($d.does(Dateish),  'True',  'a-date-does-dateish');\ncheck($d.does(Any),      'True',  'and-is-an-any');\ncheck($d.does(DateTime), 'False', 'but-is-not-a-datetime');\ncheck($d.isa(Dateish),   'False', 'isa-rejects-a-role');\ncheck($d.isa(Date),      'True',  'isa-accepts-its-own-class');\ncheck($d.isa(Any),       'True',  'isa-accepts-an-ancestor');\ncheck(($d ~~ Dateish).Bool,  'True',  'smartmatch-agrees-with-does');\ncheck(($d ~~ Any).Bool,      'True',  'smartmatch-any');\ncheck(($d ~~ DateTime).Bool, 'False', 'smartmatch-rejects-the-wrong-class');\ncheck((Date ~~ Dateish).Bool, 'True', 'the-type-object-does-it-too');\n# the numeric tower keeps the same split\ncheck(5.does(Numeric), 'True',  'an-int-does-numeric');\ncheck(5.isa(Numeric),  'False', 'but-is-not-an-isa-numeric');\ncheck(5.isa(Int),      'True',  'an-int-isa-int');\ncheck(Int.^mro.gist,   '((Int) (Cool) (Any) (Mu))', 'mro-excludes-roles');\n\n# Mu.new\ncheck(Mu.gist,          '(Mu)',   'the-mu-type-object');\ncheck(Mu.new.gist,      'Mu.new', 'an-instance-of-mu');\ncheck(Mu.Bool,          'False',  'a-type-object-is-false');\ncheck(Mu.new.Bool,      'True',   'an-instance-is-true');\ncheck(Mu.new.defined,   'True',   'and-defined');\ncheck(Mu.defined,       'False',  'the-type-object-is-not');\ncheck(Mu.new.^name,     'Mu',     'and-knows-its-name');\ncheck(Any.new.gist,     'Any.new', 'any-new-too');\n# the other Bool cases from the same documentation table\ncheck([1, 2, 3].Bool, 'True',  'a-full-array');\ncheck([].Bool,        'False', 'an-empty-array');\ncheck(%( hash => 'full' ).Bool, 'True', 'a-full-hash');\ncheck({}.Bool,        'False', 'an-empty-hash');\ncheck(\"\".Bool,        'False', 'the-empty-string');\ncheck(\"0\".Bool,       'True',  'the-string-zero');\ncheck(0.Bool,         'False', 'the-number-zero');\n\n# .item on either container kind\ncheck([1, 2, 3].item.raku,          '$[1, 2, 3]',    'item-on-an-array');\ncheck(%( apple => 10 ).item.raku,   '${:apple(10)}', 'item-on-a-hash');\ncheck(item([1, 2, 3]).raku,         '$[1, 2, 3]',    'the-item-sub');\ncheck(item(\"abc\").raku,             '\"abc\"',         'item-leaves-a-scalar-alone');\n\n# $obj.Capture reads through the accessors\nclass Foo { has $.foo = 42; has $.bar = 70; method bar { 'something else' } }\ncheck(Foo.new.Capture.gist, '\\(:bar(\"something else\"), :foo(42))', 'object-capture');\ncheck(Foo.new.Capture.^name, 'Capture', 'and-it-is-a-capture');\n\n# IterationEnd is a sentinel\nmy $it = Mu.iterator;\ncheck($it.pull-one.gist, '(Mu)',        'the-one-element');\ncheck($it.pull-one.gist, 'IterationEnd', 'then-the-sentinel-gists-bare');\n\nif @fail { note \"FAILED: @fail.join('; ')\"; say 'FAIL' } else { say 'PASS' }","output PASS","a",["PASS","PASS"],0,[["budget","20s"]]]]}