Permalink
Browse files

Added explicit list of vernaculars.

  • Loading branch information...
1 parent d23fe92 commit ad0b18407db9e2ebb962f1fe8da17e11ac60dede @gregordick gregordick committed Dec 8, 2014
@@ -0,0 +1,26 @@
+use strict;
+use warnings;
+
+use DivinumOfficium::Main qw(vernaculars);
+
+use Test::Simple tests => 5;
+
+# We're assuming here that the test is invoked from the parent of the t/
+# directory.
+my @vernaculars = vernaculars('web/www/horas/');
+my %vernaculars;
+@vernaculars{@vernaculars} = ();
+
+# Sanity checks on the available languages.
+ok(scalar(@vernaculars) == scalar(keys(%vernaculars)), 'No dups');
+ok(exists($vernaculars{'English'}), 'Has English');
+ok(exists($vernaculars{'Italiano'}), 'Has Italian');
+ok(!exists($vernaculars{'Latin'}), 'No Latin');
+
+# Make sure failing to load the file is fatal.
+{
+ package DivinumOfficium::Main;
+ use Test::Carp;
+ does_croak(\&::vernaculars, 'non/est/hic');
+}
+
View
@@ -0,0 +1,5 @@
+To run tests, run the following from the parent of this directory:
+
+ prove -r -I web/cgi-bin/ t
+
+The working directory really does matter as some tests depend on it.
@@ -0,0 +1,24 @@
+package DivinumOfficium::FileIO;
+
+use strict;
+use warnings;
+
+# Temporary measure: if we got here, the parent directory is on the library
+# search path, so this will work.
+BEGIN
+{
+ package DivinumOfficium::FileIO;
+ require "horas/do_io.pl";
+}
+
+BEGIN
+{
+ require Exporter;
+
+ our $VERSION = 1.00;
+ our @ISA = qw(Exporter);
+ our @EXPORT_OK = qw(do_read do_write);
+}
+
+1;
+
@@ -0,0 +1,32 @@
+package DivinumOfficium::Main;
+
+use strict;
+use warnings;
+
+use Carp;
+
+use DivinumOfficium::FileIO qw(do_read);
+
+BEGIN
+{
+ require Exporter;
+
+ our $VERSION = 1.00;
+ our @ISA = qw(Exporter);
+ our @EXPORT_OK = qw(vernaculars);
+}
+
+
+#*** vernaculars($basedir)
+# Returns a list of available vernacular languages for the datafiles rooted at
+# $basedir.
+sub vernaculars
+{
+ my $basedir = shift;
+ my @lines = do_read("$basedir/Linguae.txt") or
+ croak q(Couldn't load language list.);
+ return @lines;
+}
+
+1;
+
@@ -0,0 +1,4 @@
+English
+Magyar
+Italiano
+Deutsch
@@ -0,0 +1,3 @@
+English
+Magyar
+Italiano

0 comments on commit ad0b184

Please sign in to comment.