Permalink
Browse files

[t/spec] Some basic tests for Seq.Bool / Array.Bool.

git-svn-id: http://svn.pugscode.org/pugs@29886 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
1 parent bf43beb commit 3bf4ee56f1b9401ea6ef8de079afe2f745243427 colomon committed Feb 28, 2010
Showing with 38 additions and 0 deletions.
  1. +38 −0 S32-array/bool.t
View
@@ -0,0 +1,38 @@
+use v6;
+use Test;
+
+plan 15;
+
+{
+ my @a;
+ nok @a.Bool, '@a.Bool returns False for empty @a';
+ nok ?@a, '?@a returns False for empty @a';
+ nok @a, '@a in bool context returns False for empty @a';
+
+ @a.push: 37;
+ ok @a.Bool, '@a.Bool returns True for @a with one element';
+ ok ?@a, '?@a returns True for @a with one element';
+ ok @a, '@a in bool context returns True for @a with one element';
+
+ @a.push: -23;
+ ok @a.Bool, '@a.Bool returns True for @a with two elements';
+ ok ?@a, '?@a returns True for @a with two elements';
+ ok @a, '@a in bool context returns True for @a with two elements';
+}
+
+{
+ my @a = 4..3;
+ nok @a.Bool, '@a.Bool returns False for empty range in @a';
+ nok ?@a, '?@a returns False for empty range in @a';
+ nok @a, '@a in bool context returns False for empty range in @a';
+
+ @a = 4..6;
+ ok @a.Bool, '@a.Bool returns True for non-empty range in @a';
+ ok ?@a, '?@a returns True for non-empty range in @a';
+ ok @a, '@a in bool context returns True for non-empty range in @a';
+}
+
+# TODO: This could definitely use tests to make sure that @a.Bool only examines
+# the first (few?) elements of @a.
+
+# vim: ft=perl6

0 comments on commit 3bf4ee5

Please sign in to comment.