entityjs 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. data/README.md +18 -14
  2. data/entityjs.gemspec +1 -0
  3. data/lib/entityjs/assets.rb +13 -163
  4. data/lib/entityjs/command.rb +5 -2
  5. data/lib/entityjs/commands/build.rb +63 -23
  6. data/lib/entityjs/commands/eunit.rb +44 -0
  7. data/lib/entityjs/commands/release.rb +1 -1
  8. data/lib/entityjs/commands/server.rb +19 -4
  9. data/lib/entityjs/compile.rb +152 -0
  10. data/lib/entityjs/config.rb +8 -0
  11. data/lib/entityjs/dirc.rb +70 -17
  12. data/lib/entityjs/page.rb +106 -0
  13. data/lib/entityjs/parsers/parse_coffee.rb +12 -0
  14. data/lib/entityjs/version.rb +1 -1
  15. data/lib/entityjs.rb +18 -4
  16. data/public/qunit/qunit.css +9 -3
  17. data/public/qunit/qunit.entity.js +113 -31
  18. data/public/qunit/qunit.js +296 -235
  19. data/public/qunit/qunit.mock.js +54 -2
  20. data/public/tests.html +0 -15
  21. data/spec/javascripts/src/cycle/tween_spec.js +59 -0
  22. data/spec/javascripts/src/display/screen_spec.js +0 -15
  23. data/spec/javascripts/src/display/text_spec.js +4 -0
  24. data/spec/javascripts/src/input/mouse_spec.js +18 -18
  25. data/spec/javascripts/src/input/preventdefault_spec.js +14 -0
  26. data/spec/javascripts/src/math/drag_spec.js +2 -2
  27. data/spec/javascripts/src/math/hit_spec.js +24 -0
  28. data/spec/javascripts/src/math/point_spec.js +3 -3
  29. data/spec/javascripts/src/math/tile_spec.js +1 -1
  30. data/spec/javascripts/src/media/sound_spec.js +1 -1
  31. data/spec/javascripts/src/pattern/automap_spec.js +3 -3
  32. data/spec/javascripts/src/pattern/flicker_spec.js +2 -1
  33. data/spec/javascripts/src/util/random_spec.js +17 -0
  34. data/spec/javascripts/src/util/scene_spec.js +15 -0
  35. data/spec/lib/entityjs/assets_spec.rb +2 -201
  36. data/spec/lib/entityjs/commands/build_spec.rb +18 -5
  37. data/spec/lib/entityjs/commands/eunit_spec.rb +18 -0
  38. data/spec/lib/entityjs/commands/release_spec.rb +2 -0
  39. data/spec/lib/entityjs/compile_spec.rb +204 -0
  40. data/spec/lib/entityjs/dirc_spec.rb +8 -4
  41. data/spec/lib/entityjs/page_spec.rb +59 -0
  42. data/spec/support/factories.rb +0 -2
  43. data/src/core/entity.js +4 -18
  44. data/src/core/query.js +1 -1
  45. data/src/core/re.js +6 -6
  46. data/src/core/system.js +17 -12
  47. data/src/cycle/tween.js +93 -31
  48. data/src/display/align.js +11 -6
  49. data/src/display/circle.js +5 -4
  50. data/src/display/imgtext.js +33 -22
  51. data/src/display/screen.js +0 -8
  52. data/src/display/text.js +37 -4
  53. data/src/input/keyboard.js +15 -5
  54. data/src/input/mouse.js +15 -25
  55. data/src/input/preventdefault.js +11 -0
  56. data/src/math/body.js +35 -16
  57. data/src/math/drag.js +2 -2
  58. data/src/math/force.js +2 -2
  59. data/src/math/hit.js +15 -6
  60. data/src/math/hitmap.js +6 -6
  61. data/src/math/point.js +1 -1
  62. data/src/math/tile.js +22 -17
  63. data/src/media/sound.js +1 -1
  64. data/src/pattern/automap.js +16 -27
  65. data/src/pattern/flicker.js +9 -5
  66. data/src/util/random.js +4 -0
  67. data/src/util/scene.js +2 -6
  68. data/templates/arrow_keys/scripts/{display → displays}/arrow.js +0 -0
  69. data/templates/arrow_keys/scripts/{input → inputs}/controls.js +0 -0
  70. data/templates/arrow_keys/tests/{display → displays}/arrow_test.js +1 -1
  71. data/templates/arrow_keys/tests/{input → inputs}/controls_test.js +0 -0
  72. data/templates/arrow_keys/tests/scenes/load_test.js +2 -0
  73. data/templates/{blank → circle}/config.yml +0 -0
  74. data/templates/{blank → circle}/readme.txt +0 -0
  75. data/templates/circle/scripts/init.js +7 -0
  76. data/templates/circle/scripts/scenes/home.js +62 -0
  77. data/templates/circle/scripts/scenes/load.js +11 -0
  78. data/templates/circle/tests/scenes/home_test.js +29 -0
  79. data/templates/circle/tests/scenes/load_test.js +15 -0
  80. data/templates/platform/config.yml +2 -1
  81. data/templates/platform/readme.txt +15 -16
  82. data/templates/platform/scripts/{display → displays}/bit.js +0 -0
  83. data/templates/platform/scripts/{display → displays}/hero.js +0 -0
  84. data/templates/platform/scripts/{display → displays}/tile.js +0 -0
  85. data/templates/platform/scripts/{display → displays}/tsprite.js +0 -0
  86. data/templates/platform/{assets → scripts}/levels/level1.tmx +0 -0
  87. data/templates/platform/scripts/{util → utils}/counter.js +0 -0
  88. data/templates/platform/scripts/{util → utils}/level.js +0 -0
  89. data/templates/platform/tests/{display → displays}/bit_test.js +1 -1
  90. data/templates/platform/tests/displays/hero_test.js +73 -0
  91. data/templates/platform/tests/{display → displays}/tile_test.js +1 -1
  92. data/templates/platform/tests/displays/tsprite_test.js +8 -0
  93. data/templates/platform/tests/items/coin_test.js +10 -10
  94. data/templates/platform/tests/items/item_test.js +9 -9
  95. data/templates/platform/tests/items/spring_test.js +3 -3
  96. data/templates/platform/tests/scenes/load_test.js +2 -1
  97. data/templates/platform/tests/{util → utils}/counter_test.js +2 -2
  98. data/templates/platform/tests/{util → utils}/level_test.js +3 -0
  99. data/templates/pong/config.yml +22 -0
  100. data/templates/pong/readme.txt +3 -0
  101. data/templates/pong/scripts/controls/ai.js +30 -0
  102. data/templates/pong/scripts/controls/arena.js +33 -0
  103. data/templates/pong/scripts/controls/hitmap.js +54 -0
  104. data/templates/pong/scripts/controls/player.js +24 -0
  105. data/templates/pong/scripts/controls/twoarena.js +14 -0
  106. data/templates/pong/scripts/displays/ball.js +29 -0
  107. data/templates/pong/scripts/displays/counter.js +22 -0
  108. data/templates/pong/scripts/displays/paddle.js +22 -0
  109. data/templates/pong/scripts/init.js +9 -0
  110. data/templates/pong/scripts/scenes/game.js +61 -0
  111. data/templates/pong/scripts/scenes/home.js +55 -0
  112. data/templates/pong/scripts/scenes/over.js +29 -0
  113. data/templates/pong/tests/controls/ai_test.js +34 -0
  114. data/templates/pong/tests/controls/arena_test.js +20 -0
  115. data/templates/pong/tests/controls/hitmap_test.js +89 -0
  116. data/templates/pong/tests/controls/player_test.js +25 -0
  117. data/templates/pong/tests/controls/twoarena_test.js +7 -0
  118. data/templates/pong/tests/displays/ball_test.js +10 -0
  119. data/templates/pong/tests/displays/counter_test.js +13 -0
  120. data/templates/pong/tests/displays/paddle_test.js +17 -0
  121. data/templates/pong/tests/scenes/game_test.js +16 -0
  122. data/templates/pong/tests/scenes/home_test.js +30 -0
  123. data/templates/pong/tests/scenes/over_test.js +16 -0
  124. data/templates/tiltmaze/config.yml +25 -0
  125. data/templates/tiltmaze/readme.txt +79 -0
  126. data/templates/tiltmaze/scripts/displays/ball.js +78 -0
  127. data/templates/tiltmaze/scripts/displays/target.js +13 -0
  128. data/templates/tiltmaze/scripts/displays/tile.js +2 -0
  129. data/templates/tiltmaze/scripts/init.js +7 -0
  130. data/templates/tiltmaze/scripts/levels/level1.json +14 -0
  131. data/templates/tiltmaze/scripts/levels/level2.json +14 -0
  132. data/templates/tiltmaze/scripts/levels/level3.json +14 -0
  133. data/templates/tiltmaze/scripts/levels/level4.json +15 -0
  134. data/templates/tiltmaze/scripts/levels/level5.json +18 -0
  135. data/templates/tiltmaze/scripts/scenes/game.js +56 -0
  136. data/templates/tiltmaze/scripts/scenes/home.js +24 -0
  137. data/templates/tiltmaze/scripts/structs/level.js +82 -0
  138. data/templates/tiltmaze/scripts/tiles/walltile.js +147 -0
  139. data/templates/tiltmaze/tests/displays/ball_test.js +67 -0
  140. data/templates/tiltmaze/tests/displays/target_test.js +8 -0
  141. data/templates/tiltmaze/tests/factories.js +38 -0
  142. data/templates/tiltmaze/tests/scenes/game_test.js +59 -0
  143. data/templates/tiltmaze/tests/scenes/home_test.js +7 -0
  144. data/templates/tiltmaze/tests/structs/level_test.js +44 -0
  145. data/templates/tiltmaze/tests/tiles/walltile_test.js +36 -0
  146. metadata +106 -33
  147. data/templates/platform/tests/display/hero_test.js +0 -73
  148. data/templates/platform/tests/display/tsprite_test.js +0 -8
@@ -1,15 +1,43 @@
1
+ //TODO: fix up
2
+ /*
3
+
4
+ Implements:
5
+
6
+ //expects the method to be called before the end of the test
7
+ expectCall(re, 'pressed')
8
+
9
+ //expects a method to be called with the given arguments
10
+ expectCall(re, 'pressed', ['a'])
11
+
12
+ //expects a method to be called a number of times
13
+ expectCall(re, 'pressed', null, 2)
14
+
15
+ //stubs a method with a custom method
16
+ stub(re, 'pressed', function(value){
17
+ return false;
18
+ });
19
+
20
+ //method does nothing
21
+ stub(re, 'pressed');
22
+
23
+ //method returns 10
24
+ stub(re, 'pressed', 10);
25
+
26
+ */
1
27
  (function() {
2
28
  var expectCall, finishMock, mock, mocked, mocking, stack, stub, testExpectations;
3
29
  var __slice = Array.prototype.slice;
4
30
  mocking = null;
5
31
  stack = [];
6
- expectCall = function(object, method, calls) {
32
+ expectCall = function(object, method, args, calls) {
7
33
  var expectation;
8
34
  calls = (typeof calls !== "undefined" && calls !== null) ? calls : 1;
35
+
9
36
  expectation = {
10
37
  object: object,
11
38
  method: method,
12
39
  expectedCalls: calls,
40
+ expectedArgs: args,
13
41
  originalMethod: object[method],
14
42
  callCount: 0
15
43
  };
@@ -17,12 +45,25 @@
17
45
  var args;
18
46
  args = __slice.call(arguments, 0);
19
47
  expectation.originalMethod.apply(object, args);
48
+
49
+ expectation.args = args;
50
+
20
51
  return expectation.callCount += 1;
21
52
  };
22
53
  return mocking.expectations.push(expectation);
23
54
  };
24
55
  stub = function(object, method, fn) {
25
56
  var stb;
57
+
58
+ if(fn == null){
59
+ fn = function(){};
60
+ } else if(typeof fn != 'function'){
61
+ var value = fn;
62
+ fn = function(){
63
+ return value;
64
+ };
65
+ }
66
+
26
67
  stb = {
27
68
  object: object,
28
69
  method: method,
@@ -56,7 +97,18 @@
56
97
  var _a, expectation, stb;
57
98
  while (mocking.expectations.length > 0) {
58
99
  expectation = mocking.expectations.pop();
59
- equals(expectation.callCount, expectation.expectedCalls, "method " + (expectation.method) + " should be called " + (expectation.expectedCalls) + " times");
100
+ equal(expectation.callCount, expectation.expectedCalls, "method " + (expectation.method) + " should be called " + (expectation.expectedCalls) + " times");
101
+
102
+ if(expectation.expectedArgs){
103
+ //equal(expectation.expectedArgs.length, expectation.args.length, "method " + (expectation.method) + " should have " + (expectation.expectedArgs.length) + " arguments")
104
+
105
+ //check args
106
+ var eargs = expectation.expectedArgs;
107
+ var args = expectation.args;
108
+ ok(!(eargs>args || eargs<args), "method "+ expectation.method +" should have same arguments");
109
+
110
+ }
111
+
60
112
  expectation.object[expectation.method] = expectation.originalMethod;
61
113
  }
62
114
  _a = [];
data/public/tests.html CHANGED
@@ -14,23 +14,8 @@
14
14
  }
15
15
  </style>
16
16
 
17
- <script type="text/javascript" src="qunit/qunit.js"></script>
18
- <script type="text/javascript" src="qunit/qunit.mock.js"></script>
19
- <script type="text/javascript" src="qunit/qunit.input.js"></script>
20
- <script type="text/javascript" src="qunit/qunit.entity.js"></script>
21
-
22
17
  $JS
23
18
 
24
- <script type="text/javascript">
25
- //disable re.ready to test functionality
26
- re.ready.c = [];
27
-
28
- window.onload = function(){
29
- //auto start system for helpfulness
30
- re.sys.init(re.canvas).start();
31
- };
32
- </script>
33
-
34
19
  </head>
35
20
  <body>
36
21
  <h1 id="qunit-header">Game Test Suite</h1>
@@ -0,0 +1,59 @@
1
+ describe('cycle/tween', function(){
2
+
3
+ var tween;
4
+
5
+ beforeEach(function(){
6
+ tween = re.e('tween');
7
+ tween.x = 0;
8
+ tween.y = 0;
9
+ });
10
+
11
+ it('should move object', function(){
12
+ var called = false, calledUpdate = false, calledFinish = false;
13
+
14
+ tween.on('tween:update', function(){
15
+ calledUpdate = true;
16
+ })
17
+
18
+ tween.on('tween:finish', function(){
19
+ calledFinish = true;
20
+ })
21
+
22
+ tween.on('tween:start', function(){
23
+ called = true;
24
+ })
25
+
26
+ tween.tween(0, {x:100});
27
+
28
+ for(var i=60; i--;)
29
+ tween.tween_update(re.sys.stepSize)
30
+
31
+ eq(tween.x, 100);
32
+ ok(called)
33
+ ok(calledUpdate)
34
+ ok(calledFinish)
35
+ });
36
+
37
+ it('should move object in 60ms', function(){
38
+
39
+ tween.comp('tile');
40
+
41
+ tween.x = -10;
42
+ tween.tween(1, {x:50, tileY:10});
43
+
44
+ var step = re.sys.stepSize;
45
+
46
+ tween.tween_time = tween.tween_t * 0.5;
47
+
48
+ tween.tween_update(step)
49
+
50
+ eq(tween.x, 23.240000000000002);
51
+
52
+ for(var i=60; i--;)
53
+ tween.tween_update(step);
54
+
55
+ eq(tween.x, 50);
56
+ eq(tween.tileY(), 10);
57
+ });
58
+
59
+ });
@@ -29,19 +29,4 @@ describe('screen', function(){
29
29
  is(e.toScreenY(10))
30
30
  });
31
31
 
32
- it('toscreen', function(){
33
-
34
- var k = e.toScreen(10, 2);
35
- eq(k.x, 10)
36
- eq(k.y, 2)
37
-
38
- k = e.toScreen({posX:3, posY:1})
39
- eq(k.x, 3)
40
- eq(k.y, 1)
41
-
42
- k = e.toScreen({x:6, y:5})
43
- eq(k.x, 6)
44
- eq(k.y, 5)
45
- })
46
-
47
32
  });
@@ -24,7 +24,11 @@ describe('text', function(){
24
24
  })
25
25
 
26
26
  it('should draw', function(){
27
+ f.text('m\nlinesdfsdfsdfsdsdfsdfsdfsdfsdfsfsf')
27
28
  is(f.draw(re.sys.context))
29
+
30
+ //make sure correct width is set
31
+ ok(f.sizeX > 40)
28
32
  })
29
33
 
30
34
  })
@@ -15,8 +15,8 @@ describe('mouse', function(){
15
15
  is(m)
16
16
  is(m.screenX)
17
17
  is(m.screenY)
18
- is(m.x)
19
- is(m.y)
18
+ is(m.posX)
19
+ is(m.posY)
20
20
  });
21
21
 
22
22
  e.on(type+':middle', function(m, e){
@@ -24,7 +24,7 @@ describe('mouse', function(){
24
24
  is(m)
25
25
  })
26
26
 
27
- re.c('mouse').event({type:type, pageX:0, pageY:0}, 'middle')
27
+ re.c('mouse').event({type:type, offsetX:0, offsetY:0}, 'middle')
28
28
 
29
29
  ok(called2)
30
30
  ok(called)
@@ -39,8 +39,8 @@ describe('mouse', function(){
39
39
  is(m)
40
40
  is(m.screenX)
41
41
  is(m.screenY)
42
- is(m.x)
43
- is(m.y)
42
+ is(m.posX)
43
+ is(m.posY)
44
44
  });
45
45
 
46
46
  e.on(type+':middle', function(m, e){
@@ -48,7 +48,7 @@ describe('mouse', function(){
48
48
  is(m)
49
49
  })
50
50
 
51
- re.c('mouse').event({type:type, pageX:0, pageY:0}, 'middle')
51
+ re.c('mouse').event({type:type, offsetX:0, offsetY:0}, 'middle')
52
52
 
53
53
  ok(called2)
54
54
  ok(called)
@@ -65,11 +65,11 @@ describe('mouse', function(){
65
65
  is(m)
66
66
  is(m.screenX)
67
67
  is(m.screenY)
68
- is(m.x)
69
- is(m.y)
68
+ is(m.posX)
69
+ is(m.posY)
70
70
  });
71
71
 
72
- re.c('mouse').event({type:type, pageX:0, pageY:0})
72
+ re.c('mouse').event({type:type, offsetX:0, offsetY:0})
73
73
 
74
74
  ok(called)
75
75
  });
@@ -84,11 +84,11 @@ describe('mouse', function(){
84
84
  is(m)
85
85
  is(m.screenX)
86
86
  is(m.screenY)
87
- is(m.x)
88
- is(m.y)
87
+ is(m.posX)
88
+ is(m.posY)
89
89
  });
90
90
 
91
- re.c('mouse').event({type:type, pageX:0, pageY:0})
91
+ re.c('mouse').event({type:type, offsetX:0, offsetY:0})
92
92
 
93
93
  ok(called)
94
94
  })
@@ -103,11 +103,11 @@ describe('mouse', function(){
103
103
  is(m)
104
104
  is(m.screenX)
105
105
  is(m.screenY)
106
- is(m.x)
107
- is(m.y)
106
+ is(m.posX)
107
+ is(m.posY)
108
108
  });
109
109
 
110
- re.c('mouse').event({type:type, pageX:0, pageY:0})
110
+ re.c('mouse').event({type:type, offsetX:0, offsetY:0})
111
111
 
112
112
  ok(called)
113
113
  })
@@ -122,11 +122,11 @@ describe('mouse', function(){
122
122
  is(m)
123
123
  is(m.screenX)
124
124
  is(m.screenY)
125
- is(m.x)
126
- is(m.y)
125
+ is(m.posX)
126
+ is(m.posY)
127
127
  });
128
128
 
129
- re.c('mouse').event({type:type, pageX:0, pageY:0})
129
+ re.c('mouse').event({type:type, offsetX:0, offsetY:0})
130
130
 
131
131
  ok(called)
132
132
  })
@@ -0,0 +1,14 @@
1
+ describe('input/preventdefault', function(){
2
+
3
+ it('should save prevent default', function(){
4
+
5
+ var d = 'left right';
6
+
7
+ re.preventDefault(d)
8
+
9
+ ok(re.preventDefault.d['left'])
10
+ ok(re.preventDefault.d['right'])
11
+
12
+ })
13
+
14
+ });
@@ -16,7 +16,7 @@ describe('drag', function(){
16
16
  .on('drag:update', function(){
17
17
  called2 = true;
18
18
  })
19
- .on('drag:end', function(){
19
+ .on('drag:finish', function(){
20
20
  called3 = true;
21
21
  })
22
22
 
@@ -29,7 +29,7 @@ describe('drag', function(){
29
29
 
30
30
  ok(called2)
31
31
 
32
- is(e.dragEnd());
32
+ is(e.dragFinish());
33
33
 
34
34
  ok(called3)
35
35
 
@@ -25,4 +25,28 @@ describe('hit', function(){
25
25
  not(e.hit({x:100, y:0, w:30, h:30}))
26
26
  })
27
27
 
28
+ it('should hit object with reg', function(){
29
+
30
+ e.sizeX = 6;
31
+ e.sizeY = 6;
32
+ e.regX = 3;
33
+ e.regY = 3;
34
+
35
+ not(e.hit({x:-3.1, y:-3.1, w:6, h:6, regX:6, regY:6}));
36
+
37
+ });
38
+
39
+ it('should hit object with op reg', function(){
40
+
41
+ e.sizeX = 6;
42
+ e.sizeY = 6;
43
+ e.regX = 6;
44
+ e.regY = 6;
45
+ e.posX = -3.1;
46
+ e.posY = -3.1;
47
+
48
+ not(e.hit({x:0, y:0, w:6, h:6, regX:3, regY:3}));
49
+
50
+ });
51
+
28
52
  });
@@ -36,7 +36,7 @@ describe('point', function(){
36
36
  it('should be correct distance', function(){
37
37
  e.posX = 12;
38
38
  e.posY = 54;
39
- eq(e.distanceTo(23,74), 23)
39
+ eq(e.distance(23,74), 23)
40
40
  })
41
41
 
42
42
  it('should be correct distance with from', function(){
@@ -46,12 +46,12 @@ describe('point', function(){
46
46
 
47
47
  var o = {x:23, y:74}
48
48
 
49
- eq(e.distanceTo(o), 23)
49
+ eq(e.distance(o), 23)
50
50
 
51
51
 
52
52
  o = {posX:23, posY:74}
53
53
 
54
- eq(e.distanceTo(o), 23)
54
+ eq(e.distance(o), 23)
55
55
  })
56
56
 
57
57
  });
@@ -58,7 +58,7 @@ describe('tile', function(){
58
58
  eq(e.posX, 80)
59
59
  eq(e.posY, 40)
60
60
 
61
- is(e.tile({posX:2, posY:2}))
61
+ is(e.tile({posX:2 * e.sizeX, posY:2 * e.sizeY}))
62
62
 
63
63
  eq(e.posX, 80)
64
64
  eq(e.posY, 80)
@@ -9,7 +9,7 @@ describe('sound', function(){
9
9
  it('play', function(){
10
10
  var called = false;
11
11
 
12
- k = e.on('sound:end', function(){
12
+ k = e.on('sound:finish', function(){
13
13
  called = true;
14
14
  })
15
15
 
@@ -61,7 +61,7 @@ describe('automap', function(){
61
61
  eq(e.automap(0, 0), 1)
62
62
  eq(e.automap(0, 1), 6)
63
63
 
64
- eq(e.map, level)
64
+ eq(e._automap, level)
65
65
  })
66
66
 
67
67
  it('should contain right length', function(){
@@ -85,8 +85,8 @@ describe('automap', function(){
85
85
 
86
86
  eq(e.lenX, m[0].length)
87
87
  eq(e.lenY, m.length)
88
- eq(e.map.length, m.length)
89
- eq(e.map[0].length, m[0].length)
88
+ eq(e._automap.length, m.length)
89
+ eq(e._automap[0].length, m[0].length)
90
90
 
91
91
  });
92
92
 
@@ -19,6 +19,7 @@ describe('flicker', function(){
19
19
  e.addFlicker('heal', 5, 200, [10])
20
20
 
21
21
  is(e.flicker_reels['heal'])
22
+
22
23
  });
23
24
 
24
25
  it('removeFlicker', function(){
@@ -42,7 +43,7 @@ describe('flicker', function(){
42
43
  e.on('flicker:start', function(){
43
44
  called = true;
44
45
  })
45
- .on('flicker:end', function(v){
46
+ .on('flicker:finish', function(v){
46
47
  called2 = true;
47
48
  is(v, 'string')
48
49
  })
@@ -20,6 +20,23 @@ describe('random', function(){
20
20
 
21
21
  });
22
22
 
23
+ it('should get one or the other', function(){
24
+
25
+ var first = false;
26
+ var second = false;
27
+
28
+ for(var i = 100; i--;){
29
+ var n = re.random([-10, 10]);
30
+ if(n == 10) first = true;
31
+ if(n == -10) second = true;
32
+ ok(n == -10 || n == 10)
33
+ }
34
+
35
+ ok(first)
36
+ ok(second)
37
+
38
+ });
39
+
23
40
  it('random -10 to 10', function(){
24
41
 
25
42
  for(var i = 100; i--;){
@@ -49,4 +49,19 @@ describe('test', function(){
49
49
 
50
50
  })
51
51
 
52
+ it('should exit once', function(){
53
+
54
+ var called = 0;
55
+
56
+ re.scene('bob')
57
+ .exit(function(){
58
+ called++;
59
+ }).enter();
60
+
61
+ re.scene('blah').enter(10);
62
+
63
+ eq(called, 1);
64
+
65
+ });
66
+
52
67
  });