Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add tests for addressFor()

  • Loading branch information...
commit fea37e9cf5fd93a13a0e4b666c738582edfc0796 1 parent e637b70
@Twisol Twisol authored
Showing with 15 additions and 1 deletion.
  1. +15 −1 test/cpu_test.js
View
16 test/cpu_test.js
@@ -3,7 +3,21 @@ var assert = require("assert");
module.exports = {
'test CPU#addressFor': function() {
- // TODO
+ var cpu = new CPU();
+ var registers = ["a", "b", "c", "x", "y", "z", "i", "j"];
+
+ cpu.set(0x0000, 4);
+ for (var i = 0, _len = registers.length; i < _len; ++i) {
+ cpu.set("pc", 0x0000);
+ cpu.set(registers[i], 0xF0F0 + i);
+ cpu.set(0xF0F0 + i, 42);
+
+ assert(cpu.addressFor(i), registers[i]);
+ assert(cpu.addressFor(i+8), 0xF0F0 + i);
+ assert(cpu.addressFor(i+16), 42);
+ }
+
+ // TODO: rest of the value types
},
'test CPU#nextInstruction': function() {
Please sign in to comment.
Something went wrong with that request. Please try again.