Created
November 27, 2016 04:11
-
-
Save zoffixznet/1065ba0bf15c06c036d15d735a498cf3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Test; | |
plan 22; | |
sub infix:<Meqv> { @^a == @^b && all @a Zeqv @b } | |
my @a = 1 , 2 , 3 ; | |
my @b = '1', '2', '3'; | |
ok [1, 2, 3] Meqv @a, 'Array matches Array (Int)'; | |
ok (1, 2, 3) Meqv @a, 'List matches Array (Int)'; | |
ok Seq(1, 2, 3) Meqv @a, 'Seq matches Array (Int)'; | |
ok ['1', '2', '3'] Meqv @b, 'Array matches Array (Str)'; | |
ok ('1', '2', '3') Meqv @b, 'List matches Array (Str)'; | |
ok Seq('1', '2', '3') Meqv @b, 'Seq matches Array (Int)'; | |
nok [1, '2', 3] Meqv @a, 'A-A: Type mismatch fails'; | |
nok @a Meqv [1, '2', 3], 'A-A: Type mismatch fails (Flipped)'; | |
nok (1, '2', 3) Meqv @a, 'L-A: Type mismatch fails'; | |
nok @a Meqv (1, '2', 3), 'L-A: Type mismatch fails (Flipped)'; | |
nok Seq(1, '2', 3) Meqv @a, 'S-A: Type mismatch fails'; | |
nok @a Meqv Seq(1, '2', 3), 'S-A: Type mismatch fails (Flipped)'; | |
nok [1, 2, 3, 4] Meqv @a, 'A-A: Elem mismatch fails'; | |
nok @a Meqv [1, 2, 3, 4], 'A-A: Elem mismatch fails (Flipped)'; | |
nok (1, 2, 3, 4) Meqv @a, 'L-A: Elem mismatch fails'; | |
nok @a Meqv (1, 2, 3, 4), 'L-A: Elem mismatch fails (Flipped)'; | |
nok Seq(1, 2, 3, 4) Meqv @a, 'S-A: Elem mismatch fails'; | |
nok @a Meqv Seq(1, 2, 3, 4), 'S-A: Elem mismatch fails (Flipped)'; | |
# This would fool Z== | |
nok [1, (1, 2), 3] Meqv @a, 'Coercion test passes'; | |
nok @a Meqv [1, (1, 2), 3], 'Coercion test passes (Flipped)'; | |
# This would fool Z~~ | |
nok [1, True, 3] Meqv @a, 'Bool test passes'; | |
nok @a Meqv [1, True, 3], 'Bool test passes (Flipped)'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment