Commits

Shlomi Fish committed e8ef677

Implemented the first .rand() test.

  • Participants
  • Parent commits c77b8ed

Comments (0)

Files changed (2)

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

                 ], 'solves Brain-Bashers-2010-12-22');
     });
 
-    module("MicrosofRand");
+    module("MicrosoftRand");
 
     test("MicrosoftRand Seed 1", function() {
-        expect(1);
+        expect(2);
 
         var r = new ABC_Path.MicrosoftRand({seed : 1 });
 
         // TEST
         ok (r, 'r was initialized.');
+
+        // TEST
+        equals(r.rand(), 41, "First result for seed 1 is 41.");
     });
 }

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

     has: {
         seed: { is: rw, },
     },
+    methods: {
+        rand: function() {
+            this.setSeed((this.getSeed() * 214013 + 2531011) & 0x7FFFFFFF);
+            return ((this.getSeed() >> 16) & 0x7fff);
+        },
+    },
 });