summaryrefslogtreecommitdiff
path: root/t/lib
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2021-07-07 15:20:39 +1000
committerTony Cook <tony@develop-help.com>2021-08-10 15:44:59 +1000
commit7e18321c957fcae8d9b16428c51f22dea10040b1 (patch)
tree3c2aba9d5c717e3cc4424cc6795a7181f7ebfe0e /t/lib
parenteb52e36c180822dd227f1e3d507abb79d07d45ef (diff)
downloadperl-7e18321c957fcae8d9b16428c51f22dea10040b1.tar.gz
Provide a simple API for testing features enabled
Inspired by discussion in #p5p. This calls caller() itself rather than taking hints and hints_hash parameters so if we end up adding an extra hints word callers won't need to adjust their code.
Diffstat (limited to 't/lib')
-rw-r--r--t/lib/feature/api48
1 files changed, 48 insertions, 0 deletions
diff --git a/t/lib/feature/api b/t/lib/feature/api
new file mode 100644
index 0000000000..d31a8c6c6d
--- /dev/null
+++ b/t/lib/feature/api
@@ -0,0 +1,48 @@
+Test the API
+
+__END__
+# NAME test feature enabled by bundle
+use feature ();
+BEGIN {
+ print "default: ", join(" ", feature::features_enabled(0)), "\n";
+ print "unicode_strings ", feature::feature_enabled("unicode_strings", 0) ? "is" : "is not",
+ " enabled\n";
+ print "bundle: ", feature::feature_bundle(0) // "undef", "\n";
+}
+use v5.12;
+BEGIN {
+ print "5.12: ", join(" ", feature::features_enabled(0)), "\n";
+ print "unicode_strings ", feature::feature_enabled("unicode_strings", 0) ? "is" : "is not",
+ " enabled\n";
+ print "bundle: ", feature::feature_bundle(0) // "undef", "\n";
+}
+EXPECT
+default: bareword_filehandles indirect multidimensional
+unicode_strings is not enabled
+bundle: default
+5.12: bareword_filehandles indirect multidimensional say state switch unicode_strings
+unicode_strings is enabled
+bundle: 5.11
+########
+# NAME test features enabled explicitly
+no feature "indirect";
+BEGIN {
+ print "no feature indirect: ", join(" ", feature::features_enabled(0)), "\n";
+ print "indirect ", feature::feature_enabled("indirect", 0) ? "is" : "is not",
+ " enabled\n";
+ print "bundle: ", feature::feature_bundle(0) // "undef", "\n";
+}
+use feature "unicode_strings";
+BEGIN {
+ print "added unicode_strings: ", join(" ", feature::features_enabled(0)), "\n";
+ print "unicode_strings ", feature::feature_enabled("unicode_strings", 0) ? "is" : "is not",
+ " enabled\n";
+ print "bundle: ", feature::feature_bundle(0) // "undef", "\n";
+}
+EXPECT
+no feature indirect: bareword_filehandles multidimensional
+indirect is not enabled
+bundle: undef
+added unicode_strings: bareword_filehandles multidimensional unicode_strings
+unicode_strings is enabled
+bundle: undef