summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/ajax/prototype/test/unit/range_test.js
diff options
context:
space:
mode:
Diffstat (limited to 'dom/tests/mochitest/ajax/prototype/test/unit/range_test.js')
-rw-r--r--dom/tests/mochitest/ajax/prototype/test/unit/range_test.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/dom/tests/mochitest/ajax/prototype/test/unit/range_test.js b/dom/tests/mochitest/ajax/prototype/test/unit/range_test.js
new file mode 100644
index 0000000000..bcf5acb0b5
--- /dev/null
+++ b/dom/tests/mochitest/ajax/prototype/test/unit/range_test.js
@@ -0,0 +1,58 @@
+new Test.Unit.Runner({
+
+ testInclude: function() {
+ this.assert(!$R(0, 0, true).include(0));
+ this.assert($R(0, 0, false).include(0));
+
+ this.assert($R(0, 5, true).include(0));
+ this.assert($R(0, 5, true).include(4));
+ this.assert(!$R(0, 5, true).include(5));
+
+ this.assert($R(0, 5, false).include(0));
+ this.assert($R(0, 5, false).include(5));
+ this.assert(!$R(0, 5, false).include(6));
+ },
+
+ testEach: function() {
+ var results = [];
+ $R(0, 0, true).each(function(value) {
+ results.push(value);
+ });
+
+ this.assertEnumEqual([], results);
+
+ results = [];
+ $R(0, 3, false).each(function(value) {
+ results.push(value);
+ });
+
+ this.assertEnumEqual([0, 1, 2, 3], results);
+ },
+
+ testAny: function() {
+ this.assert(!$R(1, 1, true).any());
+ this.assert($R(0, 3, false).any(function(value) {
+ return value == 3;
+ }));
+ },
+
+ testAll: function() {
+ this.assert($R(1, 1, true).all());
+ this.assert($R(0, 3, false).all(function(value) {
+ return value <= 3;
+ }));
+ },
+
+ testToArray: function() {
+ this.assertEnumEqual([], $R(0, 0, true).toArray());
+ this.assertEnumEqual([0], $R(0, 0, false).toArray());
+ this.assertEnumEqual([0], $R(0, 1, true).toArray());
+ this.assertEnumEqual([0, 1], $R(0, 1, false).toArray());
+ this.assertEnumEqual([-3, -2, -1, 0, 1, 2], $R(-3, 3, true).toArray());
+ this.assertEnumEqual([-3, -2, -1, 0, 1, 2, 3], $R(-3, 3, false).toArray());
+ },
+
+ testDefaultsToNotExclusive: function() {
+ this.assertEnumEqual($R(-3,3), $R(-3,3,false));
+ }
+}); \ No newline at end of file