Skip to content

Commit

Permalink
added tests for power invert
Browse files Browse the repository at this point in the history
  • Loading branch information
iamcal committed May 10, 2017
1 parent 2ecc4d9 commit 65a7dd7
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 2 deletions.
4 changes: 2 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
[ ] add release tag
[ ] publish to npm

## add tests for more nodes (44/47 done)
## add tests for more nodes (45/47 done)
[x] current
[x] downstream_sense
[x] fear
[ ] force_down
[ ] force_up
[x] net
[ ] power_invert
[x] power_invert
[x] pump
[x] range_switch
[x] reverse_up
Expand Down
61 changes: 61 additions & 0 deletions test/42_power_invert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
describe("keyword: power invert", function(){

// This node is powered if and only if none of its children are powered. Can be
// destroyed by snowmelt.

it("is powered when one child is", function(){

var p = new HS.Program('power. invert powers two three');

p.tick();

expect(p.findFirstNode('power invert').isPowered()).toBe(false);
});

it("is not powered when multiple children are", function(){

var p = new HS.Program('power. invert powers powers powers');

p.tick();

expect(p.findFirstNode('power invert').isPowered()).toBe(false);
});

it("is powered when no children are", function(){

var p = new HS.Program('power. invert one two three');

p.tick();

expect(p.findFirstNode('power invert').isPowered()).toBe(true);
});

it("can be destroyed", function(){

var p = new HS.Program('power. invert snowmelt');

p.tick();
p.tick();

expect(p.findFirstNode('power invert').is_destroyed).toBe(true);
});

it("doesn't affect power once destroyed", function(){

var p = new HS.Program('power. invert snowmelt powers');

p.tick();

expect(p.findFirstNode('power invert').is_destroyed).toBe(false);
expect(p.findFirstNode('power invert').isPowered()).toBe(false);

p.tick();

expect(p.findFirstNode('power invert').is_destroyed).toBe(true);
expect(p.findFirstNode('power invert').isPowered()).toBe(true);
});



});

0 comments on commit 65a7dd7

Please sign in to comment.