Permalink
Browse files

Fix use_ok() getting confused about packages which are also functions.

Like ok or UNIVERSAL::DOES.
  • Loading branch information...
1 parent f481ab6 commit 78f0c977ca3b79a7a33592557b77b4f14ca61f32 @schwern schwern committed Mar 30, 2012
Showing with 17 additions and 1 deletion.
  1. +6 −0 Changes
  2. +1 −1 lib/Test/More.pm
  3. +10 −0 t/use_ok.t
View
@@ -1,3 +1,9 @@
+0.98_03
+ Bug Fixes
+ * use_ok() was calling class->import without quoting which could
+ cause problems if "class" is also a function.
+
+
0.98_02 Thu Nov 24 01:13:53 PST 2011
Bug Fixes
* use_ok() in 0.98_01 was leaking pragmas from inside Test::More.
View
@@ -858,7 +858,7 @@ package $pack;
\$^H = \${\$args[1]};
%^H = %{\$args[2]};
#line $line $f
-require $module; $version_check; $module->import(\@{\$args[0]});
+require $module; $version_check; '$module'->import(\@{\$args[0]});
\${\$args[1]} = \$^H;
%{\$args[2]} = %^H;
1;
View
@@ -110,4 +110,14 @@ note "Line numbers preserved"; {
::is( $caller[2], $line, " line" );
}
+
+note "not confused by functions vs class names"; {
+ $INC{"ok.pm"} = 1;
+ use_ok("ok"); # ok is a function inside Test::More
+
+ $INC{"Foo/bar.pm"} = 1;
+ sub Foo::bar { 42 }
+ use_ok("Foo::bar"); # Confusing a class name with a function name
+}
+
done_testing;

0 comments on commit 78f0c97

Please sign in to comment.