Add the following packages libalgorithm-diff-perl libspiffy-perl libtext-diff-perl...
[pkg-perl] / deb-src / libtest-base-perl / libtest-base-perl-0.54 / t / reserved_names.t
diff --git a/deb-src/libtest-base-perl/libtest-base-perl-0.54/t/reserved_names.t b/deb-src/libtest-base-perl/libtest-base-perl-0.54/t/reserved_names.t
new file mode 100644 (file)
index 0000000..9f79ee9
--- /dev/null
@@ -0,0 +1,56 @@
+use Test::Base tests => 18;
+
+for my $word (qw(
+                 BEGIN
+                 DESTROY
+                 EXPORT
+                 ISA
+                 block_accessor
+                 blocks_object
+                 description
+                 is_filtered
+                 name
+                 new
+                 run_filters
+                 seq_num
+                 set_value
+             )) {
+    my $blocks = my_blocks($word);
+    eval {$blocks->blocks};
+    like $@, qr{'$word' is a reserved name}, 
+         "$word is a bad name";
+}
+
+for my $word (qw(
+                 field
+                 const
+                 stub
+                 super
+             )) {
+    my $blocks = my_blocks($word);
+    my @blocks = $blocks->blocks;
+    eval {$blocks->blocks};
+    is "$@", '',
+       "$word is a good name";
+}
+
+sub my_blocks {
+    my $word = shift;
+    Test::Base->new->spec_string(<<"...");
+=== Fail test
+--- $word
+This is a test
+--- foo
+This is a test
+...
+}
+
+my $blocks = Test::Base->new->spec_string(<<'...');
+=== Fail test
+--- bar
+This is a test
+--- foo
+This is a test
+...
+eval {$blocks->blocks};
+is "$@", '';