optionalize DwarnN test
[p5sagit/Data-Dumper-Concise.git] / t / sugar.t
index 7375415..8c1dba0 100644 (file)
--- a/t/sugar.t
+++ b/t/sugar.t
@@ -37,3 +37,25 @@ DWARN: {
    is $warned_string,qq{"robot"\n}, 'Dwarn warns scalars correctly';
    is $bar, 'robot', 'Dwarn passes scalars through correctly';
 }
+
+DWARN_CODEREF: {
+   my $foo = ['warn', 'friend']->$Dwarn;
+   is $warned_string,qq{[\n  "warn",\n  "friend"\n]\n}, 'Dwarn warns lists';
+
+   ok eq_array($foo, ['warn','friend']), 'Dwarn passes lists through correctly';
+}
+
+DWARNN: {
+   my $loaded = eval { require Devel::ArgNames; 1 };
+   if ($loaded) {
+      my $x = [1];
+      my $foo = DwarnN $x;
+      is $warned_string, qq{\$x => [\n  1\n]\n}, 'DwarnN warns';
+
+      ok eq_array($foo, [1]), 'DwarnN passes through correctly';
+
+      DwarnN [1];
+      is $warned_string, qq{(anon) => [\n  1\n]\n}, 'DwarnN warns';
+   }
+}
+