This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #35865, #43011] FETCH after autovivifying
[perl5.git] / t / op / crypt.t
index 457be52..27c878f 100644 (file)
@@ -1,20 +1,20 @@
-#!./perl -Tw
+#!./perl -w
 
 BEGIN {
     chdir 't' if -d 't';
-    @INC = ('../lib');
+    @INC = qw(. ../lib);
 }
 
-use Config;
-
 BEGIN {
-    require Test::More;
+    use Config;
+
+    require "test.pl";
 
     if( !$Config{d_crypt} ) {
-        Test::More->import('skip_all');
+        skip_all("crypt unimplemented");
     }
     else {
-        Test::More->import(tests => 2);
+        plan(tests => 4);
     }
 }
 
@@ -29,9 +29,18 @@ BEGIN {
 # C2 (or higher) security schemes, and non-UNIX platforms.
 
 SKIP: {
-    skip "crypt unimplemented", 2, unless $Config{d_crypt};
-    
-    ok(substr(crypt("ab", "cd"), 2) ne substr(crypt("ab", "ce"), 2), "salt");
-
-    ok(crypt("HI", "HO") eq crypt(v4040.4041, "HO"), "Unicode");
+       skip ("VOS crypt ignores salt.", 1) if ($^O eq 'vos');
+       ok(substr(crypt("ab", "cd"), 2) ne substr(crypt("ab", "ce"), 2), "salt makes a difference");
 }
+
+$a = "a\xFF\x{100}";
+
+eval {$b = crypt($a, "cd")};
+like($@, qr/Wide character in crypt/, "wide characters ungood");
+
+chop $a; # throw away the wide character
+
+eval {$b = crypt($a, "cd")};
+is($@, '',                   "downgrade to eight bit characters");
+is($b, crypt("a\xFF", "cd"), "downgrade results agree");
+