1. Shlomi Fish
  2. abc-path

Commits

Shlomi Fish  committed baa1c7d
  • Participants
  • Parent commits 4654fb0
  • Branches default

Comments (0)

Files changed (2)

File abc-path/js/abc-path-test.js

View file
         deepEqual(mybase._to_xy(3*5+4), [3,4], '_to_xy(3*5+4) -> [3,4]');
     });
 
+    test("Solver.Base _y_indexes", function() {
+        expect(3);
+
+        var mybase = new ABC_Path.Solver.Base({});
+
+        // TEST
+        deepEqual(mybase._perl_range(0,2), [0,1,2], '_perl_range');
+
+        // TEST
+        deepEqual(mybase._perl_range(2,6), [2,3,4,5,6], '_perl_range #2');
+
+        // TEST
+        deepEqual(mybase._y_indexes(), mybase._perl_range(0, 4), 
+            '_y_indexes returns right value.'
+        );
+    });
 }

File abc-path/js/abc-path.js

View file
         _to_xy: function(myint) {
             return [Math.floor(myint / this.LEN()), (myint % this.LEN())];
         },
+        _perl_range: function(start, end) {
+            var ret = [];
+            
+            for (var i = start; i <= end; i++) {
+                ret.push(i);
+            }
+
+            return ret;
+        },
+        _y_indexes: function() {
+            return this._perl_range(0,4);
+        },
     },
 });