Commits

Sean Wilkinson committed 6f96ade

Added a test for the `QM.mapreduce` function

Comments (0)

Files changed (1)

 //  NOTE: I need to rewrite this junk so it uses Quanah ...
 //
 //                                                      ~~ (c) SRW, 28 Nov 2012
-//                                                  ~~ last updated 31 Jan 2013
+//                                                  ~~ last updated 01 Feb 2013
 
 (function () {
     'use strict';
 
  // Declarations
 
-    var exit, mothership, n, run_test;
+    var exit, mothership, n, queue, register_test, run_test;
 
  // Definitions
 
 
     mothership = 'http://localhost:8177';
 
-    n = 8;
+    queue = [];
+
+    register_test = function (y, f) {
+     // This function needs documentation.
+        queue.push({f: f, y: y});
+        return;
+    };
 
     run_test = function (y, f) {
      // This function needs documentation.
+        if (n === undefined) {
+            console.log('Running ' + queue.length + ' tests ...');
+            n = queue.length;
+        }
         var homepage = require('webpage').create();
         homepage.onConsoleMessage = function (message) {
          // This function needs documentation.
         return;
     };
 
- // Invocations
+ // Test definitions
 
     console.log('NOTE: Remember to launch a worker for "sean"!');
 
-    run_test('Results: 1', function f() {
+    register_test('Results: 1', function f() {
      // This function tests "Method Q" for the case when all parameters for
      // remote execution are specified explicitly to the constructor.
         /*jslint browser: true */
         return;
     });
 
-    run_test('Results: 2', function f() {
+    register_test('Results: 2', function f() {
      // This function tests "Method Q" for the case when the `box` and `val`
      // parameters are assigned after the avar has been constructed.
         /*jslint browser: true */
         return;
     });
 
-    run_test('Results: 3', function f() {
+    register_test('Results: 3', function f() {
      // This function tests `QM.submit` for the case when the input argument is
      // an object and the transform `f` is an anonymous JavaScript function.
         /*jslint browser: true */
         return;
     });
 
-    run_test('Results: 4', function f() {
+    register_test('Results: 4', function f() {
      // This function tests `QM.submit` for the case when the input arguments
      // are entered individually.
         /*jslint browser: true */
         return;
     });
 
-    run_test('Results: 5', function f() {
+    register_test('Results: 5', function f() {
      // This function tests `QM.submit` for the case when the input argument is
      // an object and the transform `f` is a CoffeeScript string.
         /*jslint browser: true */
         return;
     });
 
-    run_test('Results: 6', function f() {
+    register_test('Results: 6', function f() {
      // This function tests `QM.submit` for the case when the input argument is
      // an object and the data `x` are represented by an avar.
         /*jslint browser: true */
         return;
     });
 
-    run_test('Results: 7', function f() {
+    register_test('Results: 7', function f() {
      // This function tests `QM.submit` for the case when the input argument is
      // an object, the transform `f` is a CoffeeScript string, and the data `x`
      // are represented by an avar.
         return;
     });
 
-    run_test('Results: 8', function f() {
+    register_test('Results: 8', function f() {
      // This function tests `QM.submit` for the case when the input argument is
      // an object and the data `x` are represented by an avar with an explicit
      // `box` value. The expected behavior here is to use "sean", not "booger".
         return;
     });
 
+    register_test('Results: 45', function f() {
+     // This function needs documentation.
+        if (window.hasOwnProperty('QM') === false) {
+            setTimeout(f, 0);
+            return;
+        }
+        var mapf, redf, x;
+        mapf = '(x) -> 3 * x';
+        redf = '(a, b) -> a + b';
+        x = [1, 2, 3, 4, 5];
+        QM.mapreduce(x, mapf, redf, 'sean').Q(function (evt) {
+         // This function needs documentation.
+            console.log('Results:', this.val);
+            return evt.exit();
+        }).on('error', function (message) {
+         // This function needs documentation.
+            console.error('Error:', message);
+            return;
+        });
+        return;
+    });
+
+ // Invocations
+
+    n = queue.length;
+
+    queue.forEach(function (test, key) {
+     // This function needs documentation.
+        console.log(key + ':', test.y);
+        run_test(test.y, test.f);
+        return;
+    });
+
  // That's all, folks!
 
     return;