<commit_before>use v6;
use Test;

plan 7;

# TODO: move to S02?
# L<S02/Generic types/>

# Check it captures built-in types.
sub basic_capture(::T $x) { T }
isa_ok(basic_capture(42),  Int, 'captured built-in type');
isa_ok(basic_capture(4.2), Num, 'captured built-in type');

# User defined ones too.
class Foo { }
isa_ok(basic_capture(Foo.new), Foo, 'captured user defined type');

# Check you can use captured type later in the signature.
sub two_the_same(::T $x, T $y) { 1 }
ok(two_the_same(42, 42), 'used captured type later in the sig');
my $ok = 1;
try {
    two_the_same(42, 4.2);
    $ok = 0;
}
ok($ok, 'used captured type later in the sig');

# Check you can use them to declare variables.
sub declare_cap_type(::T $x) {
    my T $y = 4.2;<commit_msg>[t/spec] s/Num/Rat/ in a test that got behind with the spec.<commit_after>use v6;
use Test;

plan 7;

# TODO: move to S02?
# L<S02/Generic types/>

# Check it captures built-in types.
sub basic_capture(::T $x) { T }
isa_ok(basic_capture(42),  Int, 'captured built-in type');
isa_ok(basic_capture(4.2), Rat, 'captured built-in type');

# User defined ones too.
class Foo { }
isa_ok(basic_capture(Foo.new), Foo, 'captured user defined type');

# Check you can use captured type later in the signature.
sub two_the_same(::T $x, T $y) { 1 }
ok(two_the_same(42, 42), 'used captured type later in the sig');
my $ok = 1;
try {
    two_the_same(42, 4.2);
    $ok = 0;
}
ok($ok, 'used captured type later in the sig');

# Check you can use them to declare variables.
sub declare_cap_type(::T $x) {
    my T $y = 4.2;
{'fraction_non_alphanumeric': 0.14613911933631143, 'fraction_numerical': 0.029355456285896617, 'mean_word_length': 4.0256410256410255, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2984606', 'n_tokens_mistral': 633, 'n_tokens_neox': 589, 'n_words': 207}