<commit_before>my $tests := Test::PmcMatrix2D.new();
$tests.suite.run;

class Test::PmcMatrix2D is Pla::MatrixTest {

has $!factory;

INIT {
    use('UnitTest::Testcase');
    use('UnitTest::Assertions');
}

method factory() {
    unless pir::defined__IP($!factory) {
        $!factory := Pla::MatrixFactory::PMCMatrix2D.new();
    }
    return $!factory;
}

method test_VTABLE_get_integer_keyed() {
    my $m := self.factory.matrix();
    my $n := 42;
    my $o;
    Q:PIR {
        $P0 = find_lex "$m"
        $P1 = find_lex "$n"
        $P0[0;0] = $P1
        $I0 = $P0[0;0]
        $P2 = box $I0
        store_lex "$o", $P2
    };
    assert_equal($n, $o, "get_integer_keyed does not work");
}

method test_VTABLE_get_number_keyed() {
    my $m := self.factory.matrix();
    my $n := 42.5;
    my $o;
    Q:PIR {
        $P0 = find_lex "$m"
        $P1 = find_lex "$n"
        $P0[0;0] = $P1
        $N0 = $P0[0;0]
        $P2 = box $N0
        store_lex "$o", $P2
    };
    assert_equal($n, $o, "get_number_keyed does not work");
}

method test_VTABLE_get_string_keyed() {
    my $m := self.factory.matrix();
    my $n := "Hello World";
    my $o;
    Q:PIR {
        $P0 = find_lex "$m"
        $P1 = find_lex "$n"
        $P0[0;0] = $P1
        $S0 = $P0[0;0]
        $P2 = box $S0
        store_lex "$o", $P2
    };
    assert_equal($n, $o, "get_string_keyed does not work");
}

method test_VTABLE_set_integer_keyed() {
    my $m := self.factory.matrix();
    my $n;
    Q:PIR {
        $P0 = find_lex "$m"
        $I0 = 42
        $P0[0;0] = $I0
        $I1 = $P0[0;0]
        $P1 = box $I1
        store_lex "$n", $P1
    };
    assert_equal($n, 42, "set_integer_keyed does not work");
}

method test_VTABLE_set_number_keyed() {
    my $m := self.factory.matrix();
    my $n;
    Q:PIR {
        $P0 = find_lex "$m"
        $N0 = 42.5
        $P0[0;0] = $N0
        $N1 = $P0[0;0]
        $P1 = box $N1
        store_lex "$n", $P1
    };
    assert_equal($n, 42.5, "set_number_keyed does not work");
}

method test_VTABLE_set_string_keyed() {
    my $m := self.factory.matrix();
    my $n;
    Q:PIR {
        $P0 = find_lex "$m"
        $S0 = "Hello World"
        $P0[0;0] = $S0
        $S1 = $P0[0;0]
        $P1 = box $S1
        store_lex "$n", $P1
    };
    assert_equal($n, "Hello World", "set_integer_keyed does not work");
}

method test_VTABLE_get_string() {
    my $m := self.factory.matrix();
    my $n;
    Q:PIR {
        $P0 = find_lex "$m"
        $S0 = "Hello World"
        $P0[0;0] = $S0
        $S1 = $P0[0;0]
        $P1 = box $S1
        store_lex "$n", $P1
    };
    assert_equal(~($m), '{' ~ "\n\t[0,0] = Hello World\n" ~ '}' ~ "\n", "get_string does not work");
}

method test_negative_array() {
    my $m := self.factory.defaultmatrix2x2();

    assert_throws(Exception::OutOfBounds, "negative PCM array should throw exception", {
        my $e := $m{[-1]};
    });
}

method test_empty_array() {
    my $m := self.factory.defaultmatrix2x2();

    assert_throws(Exception::OutOfBounds, "empty PCM array should throw exception", {
        my $e := $m{[]};
    });
}

method test_1_element_array() {
    my $m := self.factory.fancymatrix2x2();
    $m.'item_at'(0,1,7);
    my $e := $m{[1]};

    assert_equal($e, 7, "1 element PCM array should work");
}

method test_2_elements_array() {
    my $m := self.factory.fancymatrix2x2();
    $m.'item_at'(1,1,7);
    my $e := $m{[1,1]};

    assert_equal($e, 7, "PCM array with 2 elements should work");
}

method test_more_than_2_elements_array() {
    my $m := self.factory.fancymatrix2x2();

    assert_throws(Exception::OutOfBounds, "PCM array with more than 2 elements should throw exception", {
      my $e := $m{[1,2,3]};
    });
}



method test_negative_key() {
    my $m := self.factory.defaultmatrix2x2();

    assert_throws(Exception::OutOfBounds, "negative PCM key should throw exception", {
        my $e := $m{Key.new(-1)};
    });
}

method test_empty_key() {
    my $m := self.factory.fancymatrix2x2();

    assert_throws(Exception::OutOfBounds, "empty PCM key should throw exception", {
        my $e := $m{Key.new()};
    });
}

method test_1_element_key() {
    my $m := self.factory.fancymatrix2x2();
    $m.'item_at'(0,1,7);
    my $e := $m{Key.new(1)};

    assert_equal($e, 7, "1 element PCM key should work");
}

method test_2_elements_key() {
    my $m := self.factory.fancymatrix2x2();
    $m.'item_at'(1,1,7);
    my $e := $m{Key.new(1,1)};

    assert_equal($e, 7, "PCM key with 2 elements should work");
}

method test_more_than_2_elements_key() {
    my $m := self.factory.fancymatrix2x2();

    assert_throws(Exception::OutOfBounds, "PCM keys with more than 2 elements should throw exception", {
      my $e := $m{Key.new(0,1,3)};
    });
}

}<commit_msg>Add more tests to new pmckey_to_coords() function<commit_after>my $tests := Test::PmcMatrix2D.new();
$tests.suite.run;

class Test::PmcMatrix2D is Pla::MatrixTest {

has $!factory;

INIT {
    use('UnitTest::Testcase');
    use('UnitTest::Assertions');
}

method factory() {
    unless pir::defined__IP($!factory) {
        $!factory := Pla::MatrixFactory::PMCMatrix2D.new();
    }
    return $!factory;
}

method test_VTABLE_get_integer_keyed() {
    my $m := self.factory.matrix();
    my $n := 42;
    my $o;
    Q:PIR {
        $P0 = find_lex "$m"
        $P1 = find_lex "$n"
        $P0[0;0] = $P1
        $I0 = $P0[0;0]
        $P2 = box $I0
        store_lex "$o", $P2
    };
    assert_equal($n, $o, "get_integer_keyed does not work");
}

method test_VTABLE_get_number_keyed() {
    my $m := self.factory.matrix();
    my $n := 42.5;
    my $o;
    Q:PIR {
        $P0 = find_lex "$m"
        $P1 = find_lex "$n"
        $P0[0;0] = $P1
        $N0 = $P0[0;0]
        $P2 = box $N0
        store_lex "$o", $P2
    };
    assert_equal($n, $o, "get_number_keyed does not work");
}

method test_VTABLE_get_string_keyed() {
    my $m := self.factory.matrix();
    my $n := "Hello World";
    my $o;
    Q:PIR {
        $P0 = find_lex "$m"
        $P1 = find_lex "$n"
        $P0[0;0] = $P1
        $S0 = $P0[0;0]
        $P2 = box $S0
        store_lex "$o", $P2
    };
    assert_equal($n, $o, "get_string_keyed does not work");
}

method test_VTABLE_set_integer_keyed() {
    my $m := self.factory.matrix();
    my $n;
    Q:PIR {
        $P0 = find_lex "$m"
        $I0 = 42
        $P0[0;0] = $I0
        $I1 = $P0[0;0]
        $P1 = box $I1
        store_lex "$n", $P1
    };
    assert_equal($n, 42, "set_integer_keyed does not work");
}

method test_VTABLE_set_number_keyed() {
    my $m := self.factory.matrix();
    my $n;
    Q:PIR {
        $P0 = find_lex "$m"
        $N0 = 42.5
        $P0[0;0] = $N0
        $N1 = $P0[0;0]
        $P1 = box $N1
        store_lex "$n", $P1
    };
    assert_equal($n, 42.5, "set_number_keyed does not work");
}

method test_VTABLE_set_string_keyed() {
    my $m := self.factory.matrix();
    my $n;
    Q:PIR {
        $P0 = find_lex "$m"
        $S0 = "Hello World"
        $P0[0;0] = $S0
        $S1 = $P0[0;0]
        $P1 = box $S1
        store_lex "$n", $P1
    };
    assert_equal($n, "Hello World", "set_integer_keyed does not work");
}

method test_VTABLE_get_string() {
    my $m := self.factory.matrix();
    my $n;
    Q:PIR {
        $P0 = find_lex "$m"
        $S0 = "Hello World"
        $P0[0;0] = $S0
        $S1 = $P0[0;0]
        $P1 = box $S1
        store_lex "$n", $P1
    };
    assert_equal(~($m), '{' ~ "\n\t[0,0] = Hello World\n" ~ '}' ~ "\n", "get_string does not work");
}

method test_negative_array() {
    my $m := self.factory.defaultmatrix2x2();

    assert_throws(Exception::OutOfBounds, "negative PCM array should throw exception", {
        my $e := $m{[-1]};
    });
}

method test_empty_array() {
    my $m := self.factory.defaultmatrix2x2();

    assert_throws(Exception::OutOfBounds, "empty PCM array should throw exception", {
        my $e := $m{[]};
    });
}

method test_1_element_array() {
    my $m := self.factory.fancymatrix2x2();
    $m.'item_at'(0,1,7);
    my $e := $m{[1]};

    assert_equal($e, 7, "1 element PCM array should work");
}

method test_1_element_array2() {
    my $m := self.factory.defaultmatrix3x3();
    $m.'item_at'(2,2,7);
    my $e := $m{[8]};

    assert_equal($e, 7, "1 element PCM array should work");
}

method test_2_elements_array() {
    my $m := self.factory.fancymatrix2x2();
    $m.'item_at'(1,1,7);
    my $e := $m{[1,1]};

    assert_equal($e, 7, "PCM array with 2 elements should work");
}

method test_more_than_2_elements_array() {
    my $m := self.factory.fancymatrix2x2();

    assert_throws(Exception::OutOfBounds, "PCM array with more than 2 elements should throw exception", {
      my $e := $m{[1,2,3]};
    });
}



method test_negative_key() {
    my $m := self.factory.defaultmatrix2x2();

    assert_throws(Exception::OutOfBounds, "negative PCM key should throw exception", {
        my $e := $m{Key.new(-1)};
    });
}

method test_empty_key() {
    my $m := self.factory.fancymatrix2x2();

    assert_throws(Exception::OutOfBounds, "empty PCM key should throw exception", {
        my $e := $m{Key.new()};
    });
}

method test_1_element_key() {
    my $m := self.factory.fancymatrix2x2();
    $m.'item_at'(0,1,7);
    my $e := $m{Key.new(1)};

    assert_equal($e, 7, "1 element PCM key should work");
}

method test_1_element_key2() {
    my $m := self.factory.defaultmatrix3x3();
    $m.'item_at'(2,2,7);
    my $e := $m{Key.new(8)};

    assert_equal($e, 7, "1 element PCM key should work");
}

method test_2_elements_key() {
    my $m := self.factory.fancymatrix2x2();
    $m.'item_at'(1,1,7);
    my $e := $m{Key.new(1,1)};

    assert_equal($e, 7, "PCM key with 2 elements should work");
}

method test_more_than_2_elements_key() {
    my $m := self.factory.fancymatrix2x2();

    assert_throws(Exception::OutOfBounds, "PCM keys with more than 2 elements should throw exception", {
      my $e := $m{Key.new(0,1,3)};
    });
}

}
{'fraction_non_alphanumeric': 0.1797086891009543, 'fraction_numerical': 0.036765444500251133, 'mean_word_length': 2.59942154736081, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4359907', 'n_tokens_mistral': 4086, 'n_tokens_neox': 3981, 'n_words': 862}