Shlomi Fish avatar Shlomi Fish committed d3f2c19

Convert t/format.t to Test::More.

Comments (0)

Files changed (1)

Text-Format/Text-Format/t/format.t

 
 ######################### We start with some black magic to print on failure.
 
-# Change 1..1 below to 1..last_test_to_print .
-# (It may become useful if the test is moved to ./t subdirectory.)
+use strict;
+use warnings;
 
-BEGIN { $| = 1; print "1..5\n"; }
-END {print "not ok 1\n" unless $loaded;}
-use Text::Format 0.43;
-$loaded = 1;
-print "ok 1\n";
+# Should be 5.
+use Test::More tests => 5;
+
+use Text::Format;
+
+# TEST
+ok(1, "Text::Format loaded.");
 
 ######################### End of black magic.
 
 # (correspondingly "not ok 13") depending on the success of chunk 13
 # of the test code):
 
-$text = new Text::Format;
-@text = $text->paragraphs("hello world","cool");
-if(@text == 2) {
-    print "ok 2\n";
+{
+    my $text = Text::Format->new;
+
+    my @results = $text->paragraphs("hello world","cool");
+    # TEST
+    is (scalar(@results), 2, "2 results.");
+
+    @results = $text->format("hello world","cool");
+    # TEST
+    is (scalar(@results), 1, "formatting as one line.");
+
+    @results = $text->center("hello world","cool");
+    # TEST
+    is (scalar(@results), 2, "center()");
+
+    $text->columns(10);
+    $text->bodyIndent(8);
+
+    @results = $text->format("hello world","cool");
+
+    # TEST
+    is (scalar(@results), 3, "columns and bodyIndent");
 }
-
-@text = $text->format("hello world","cool");
-if(@text == 1) {
-    print "ok 3\n";
-}
-else {
-    print "not ok 3\n";
-}
-
-@text = $text->center("hello world","cool");
-if(@text == 2) {
-    print "ok 4\n";
-}
-else {
-    print "not ok 3\n";
-}
-
-$text->columns(10);
-$text->bodyIndent(8);
-@text = $text->format("hello world","cool");
-if(@text == 3) {
-    print "ok 5\n";
-}
-else {
-    print "not ok 3\n";
-}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.