react 0.5.2 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/.travis.yml +5 -0
  2. package/Jakefile.js +39 -0
  3. package/README.md +15 -23
  4. package/browser-test/dist.html +90 -0
  5. package/browser-test/index.html +86 -0
  6. package/browser-test/min.html +90 -0
  7. package/dist/react.js +3107 -0
  8. package/dist/react.min.js +22 -0
  9. package/doc/advanced.md +10 -2
  10. package/examples/using-events1.js +1 -1
  11. package/lib/base-task.js +116 -110
  12. package/lib/cb-task.js +71 -67
  13. package/lib/core.js +116 -117
  14. package/lib/dsl.js +120 -115
  15. package/lib/error.js +44 -36
  16. package/lib/event-collector.js +69 -56
  17. package/lib/event-manager.js +81 -67
  18. package/lib/eventemitter.js +20 -0
  19. package/lib/finalcb-first-task.js +56 -53
  20. package/lib/finalcb-task.js +55 -51
  21. package/lib/id.js +18 -7
  22. package/lib/input-parser.js +49 -41
  23. package/lib/log-events.js +88 -73
  24. package/lib/parse.js +34 -25
  25. package/lib/promise-resolve.js +42 -27
  26. package/lib/promise-task.js +78 -74
  27. package/lib/react.js +59 -0
  28. package/lib/ret-task.js +59 -55
  29. package/lib/sprintf.js +18 -0
  30. package/lib/status.js +11 -2
  31. package/lib/task.js +215 -217
  32. package/lib/track-tasks.js +72 -58
  33. package/lib/validate.js +136 -136
  34. package/lib/vcon.js +78 -69
  35. package/lib/when-task.js +69 -65
  36. package/package.json +10 -9
  37. package/src/dist.build.requirejs +20 -0
  38. package/test/ast.mocha.js +136 -0
  39. package/test/cb-task.mocha.js +220 -0
  40. package/test/core-deferred.mocha.js +143 -0
  41. package/test/core-when.mocha.js +96 -0
  42. package/test/core.mocha.js +589 -0
  43. package/test/dsl.mocha.js +350 -0
  44. package/test/event-manager.mocha.js +119 -0
  45. package/test/exec-options.mocha.js +48 -0
  46. package/test/finalcb-task.mocha.js +58 -0
  47. package/test/input-parser.mocha.js +86 -0
  48. package/test/log-events.mocha.js +88 -0
  49. package/test/mocha.opts +2 -0
  50. package/test/module-use.mocha.js +147 -0
  51. package/test/promise-auto-resolve.mocha.js +68 -0
  52. package/test/ret-task.mocha.js +220 -0
  53. package/test/task.mocha.js +42 -0
  54. package/test/validate-cb-task.mocha.js +100 -0
  55. package/test/validate-ret-task.mocha.js +110 -0
  56. package/test/validate.mocha.js +324 -0
  57. package/test/vcon.mocha.js +193 -0
  58. package/vendor/chai/chai.js +2038 -0
  59. package/vendor/jquery/jquery-1.7.1.js +9266 -0
  60. package/vendor/jquery/jquery-1.7.1.min.js +4 -0
  61. package/vendor/mocha/mocha.css +135 -0
  62. package/vendor/mocha/mocha.js +3589 -0
  63. package/vendor/node/util.js +531 -0
  64. package/vendor/requirejs/require.js +2053 -0
  65. package/vendor/requirejs/require.min.js +33 -0
  66. package/react.js +0 -40
  67. package/test/ast.test.js +0 -118
  68. package/test/cb-task.test.js +0 -197
  69. package/test/core-deferred.test.js +0 -134
  70. package/test/core-promised.test.js +0 -132
  71. package/test/core-when.test.js +0 -84
  72. package/test/core.test.js +0 -593
  73. package/test/dsl.test.js +0 -330
  74. package/test/event-manager.test.js +0 -102
  75. package/test/exec-options.test.js +0 -33
  76. package/test/finalcb-task.test.js +0 -38
  77. package/test/input-parser.test.js +0 -66
  78. package/test/module-use.test.js +0 -134
  79. package/test/promise-auto-resolve.test.js +0 -52
  80. package/test/ret-task.test.js +0 -199
  81. package/test/task.test.js +0 -21
  82. package/test/validate-cb-task.test.js +0 -74
  83. package/test/validate-ret-task.test.js +0 -83
  84. package/test/validate.test.js +0 -295
  85. package/test/vcon.test.js +0 -173
@@ -0,0 +1,324 @@
1
+ 'use strict';
2
+ /*global react:true util:true sprintf:true validate:true taskUtil:true */
3
+
4
+ if (typeof(chai) === 'undefined') {
5
+ var chai = require('chai');
6
+ }
7
+
8
+ if (typeof(react) === 'undefined') {
9
+ var react = require('../'); //require('react');
10
+ }
11
+
12
+ if (typeof(util) === 'undefined') {
13
+ var util = require('util');
14
+ }
15
+
16
+ if (typeof(sprintf) === 'undefined') {
17
+ var sprintf = require('../lib/sprintf');
18
+ }
19
+
20
+ if (typeof(validate) === 'undefined') {
21
+ var validate = require('../lib/validate.js');
22
+ }
23
+
24
+ if (typeof(taskUtil) === 'undefined') {
25
+ var taskUtil = require('../lib/task.js');
26
+ }
27
+
28
+ (function () {
29
+
30
+ var t = chai.assert;
31
+
32
+ /**
33
+ Testing ...
34
+ */
35
+
36
+ suite('validate');
37
+
38
+ function foo() { }
39
+ function bar() { }
40
+
41
+ test('empty ast is invalid', function (done) {
42
+ t.deepEqual(validate(), ['ast must be an object with inParams, tasks, and outTask']);
43
+ t.deepEqual(validate({}), ['ast must be an object with inParams, tasks, and outTask']);
44
+ t.deepEqual(validate({ inParams: [] }), ['ast must be an object with inParams, tasks, and outTask']);
45
+ t.deepEqual(validate({ tasks: [] }), ['ast must be an object with inParams, tasks, and outTask']);
46
+ t.deepEqual(validate({ tasks: [], outTask: {} }), ['ast must be an object with inParams, tasks, and outTask']);
47
+ t.deepEqual(validate({ outTask: {} }), ['ast must be an object with inParams, tasks, and outTask']);
48
+ done();
49
+ });
50
+
51
+ test('ast.inParams must be an array of strings', function (done) {
52
+ var ast = {
53
+ inParams: 'a', //err should be an array
54
+ tasks: [{ f: foo, a: [], out: ['bar'], type: 'ret' }],
55
+ outTask: { a: ['bar'] }
56
+ };
57
+ t.deepEqual(validate(ast), ['ast.inParams must be an array of strings']);
58
+
59
+ ast.inParams = [1]; //err not an array of strings
60
+ t.deepEqual(validate(ast), ['ast.inParams must be an array of strings']);
61
+ done();
62
+ });
63
+
64
+ test('ast.tasks must be an array of tasks', function (done) {
65
+ var ast = {
66
+ inParams: ['a'],
67
+ tasks: 'bar', //err should be array
68
+ outTask: { a: ['bar'] }
69
+ };
70
+ t.deepEqual(validate(ast), ['ast.tasks must be an array of tasks']);
71
+ done();
72
+ });
73
+
74
+ test('each task must be an object', function (done) {
75
+ var ast = {
76
+ inParams: ['a'],
77
+ tasks: [1], //err not array of objects
78
+ outTask: { a: ['bar'] }
79
+ };
80
+ t.deepEqual(validate(ast), ['task must be an object - 1']);
81
+ done();
82
+
83
+ });
84
+
85
+
86
+ test('each task in ast.tasks must match a valid task type', function (done) {
87
+ var ast = {
88
+ inParams: ['a'],
89
+ tasks: [{ type: 'zoo', f: foo, a: [], out: ['bar'] }], //err wrong type
90
+ outTask: { a: ['bar'] }
91
+ };
92
+ var msg = sprintf('task.type should match one of %s - %s',
93
+ taskUtil.taskTypeKeys().join(', '), util.inspect(ast.tasks[0]));
94
+ t.deepEqual(validate(ast), [msg]);
95
+ done();
96
+ });
97
+
98
+ test('ast.outTask.a should be an array of string param names', function (done) {
99
+ var ast = {
100
+ inParams: ['a'],
101
+ tasks: [{ f: foo, a: [], out: ['bar'], type: 'ret' }],
102
+ outTask: { a: ['bar'] }
103
+ };
104
+ ast.outTask = {}; //err a should be an arr
105
+ var msg = sprintf('ast.outTask.a should be an array of string param names - %s',
106
+ util.inspect({ type: 'finalcb' }));
107
+ t.deepEqual(validate(ast), [msg]);
108
+
109
+ ast.outTask = { type: 'finalcb', a: 'bar' }; //err a should be an arr
110
+ msg = sprintf('ast.outTask.a should be an array of string param names - %s',
111
+ util.inspect(ast.outTask));
112
+ t.deepEqual(validate(ast), [msg]);
113
+
114
+ ast.outTask = { type: 'finalcb', a: ['bar', 1] }; //err a should be an arr of strings
115
+ msg = sprintf('ast.outTask.a should be an array of string param names - %s',
116
+ util.inspect(ast.outTask));
117
+ t.deepEqual(validate(ast), [msg]);
118
+
119
+ ast.outTask = { a: [] }; //valid
120
+ t.deepEqual(validate(ast), []);
121
+ done();
122
+ });
123
+
124
+ test('ast.tasks that specify name need to be unique', function (done) {
125
+ var ast = {
126
+ inParams: ['a'],
127
+ tasks: [
128
+ { f: foo, a: [], out: ['bar'], name: 'dog' },
129
+ { f: foo, a: [], out: ['bar'], name: 'dog' }
130
+ ],
131
+ outTask: { a: ['bar'] }
132
+ };
133
+ var msg = sprintf('ast.tasks that specify name need to be unique, duplicate: %s',
134
+ 'dog');
135
+ t.deepEqual(validate(ast), [msg]);
136
+ done();
137
+ });
138
+
139
+ test('ast.locals should be non-null if passed in', function (done) {
140
+ var ast = {
141
+ inParams: ['a'],
142
+ tasks: [{ f: foo, a: [], out: ['bar'], type: 'ret' }],
143
+ outTask: { a: ['bar'] },
144
+ locals: null //err should be non-null if passed in
145
+ };
146
+ t.deepEqual(validate(ast), ['ast.locals should not be null']);
147
+
148
+ ast.locals = { };
149
+ t.deepEqual(validate(ast), []);
150
+ done();
151
+ });
152
+
153
+ test('non-method string functions need to map to fn in locals or in params', function (done) {
154
+ var ast = {
155
+ inParams: ['a'],
156
+ tasks: [{ f: 'foo', a: [], out: ['bar'], type: 'ret' }],
157
+ outTask: { a: ['bar'] },
158
+ locals: { }
159
+ };
160
+ var msg = sprintf('function: %s not found in locals or input params - task[%s]',
161
+ 'foo', 0);
162
+ t.deepEqual(validate(ast), [msg]);
163
+ done();
164
+ });
165
+
166
+ test('string functions maps to fn in locals', function (done) {
167
+ var ast = {
168
+ inParams: ['a'],
169
+ tasks: [{ f: 'cat.bar', a: [], out: ['bar'], type: 'ret' }],
170
+ outTask: { a: ['bar'] },
171
+ locals: { cat: { bar: foo }}
172
+ };
173
+ t.deepEqual(validate(ast), []);
174
+ done();
175
+ });
176
+
177
+ test('string functions maps to fn in inputs', function (done) {
178
+ var ast = {
179
+ inParams: ['a1', 'dog'],
180
+ tasks: [{ f: 'dog.food', a: [], out: ['bar'], type: 'ret' }],
181
+ outTask: { a: ['bar'] },
182
+ locals: { }
183
+ };
184
+ t.deepEqual(validate(ast), []);
185
+ done();
186
+ });
187
+
188
+ test('string functions need to map to fn in locals or in params', function (done) {
189
+ var ast = {
190
+ inParams: ['a'],
191
+ tasks: [{ f: 'foo.bar', a: [], out: ['bar'], type: 'ret' }],
192
+ outTask: { a: ['bar'] },
193
+ locals: { foo: {}}
194
+ };
195
+ var msg = sprintf('function: %s not found in locals or input params - task[%s]',
196
+ 'foo.bar', 0);
197
+ t.deepEqual(validate(ast), [msg]);
198
+ done();
199
+ });
200
+
201
+ test('param func str fn need to map to fn in locals or in params', function (done) {
202
+ var ast = {
203
+ inParams: ['a'],
204
+ tasks: [{ f: 'a', a: [], out: ['bar'], type: 'ret' }],
205
+ outTask: { a: ['bar'] },
206
+ locals: { }
207
+ };
208
+ t.deepEqual(validate(ast), []);
209
+ done();
210
+ });
211
+
212
+ test('param obj exist func str needs map to fn in locals or in params', function (done) {
213
+ var ast = {
214
+ inParams: ['a'],
215
+ tasks: [{ f: 'a.b', a: [], out: ['bar'], type: 'ret' }],
216
+ outTask: { a: ['bar'] },
217
+ locals: { }
218
+ };
219
+ t.deepEqual(validate(ast), []);
220
+ done();
221
+ });
222
+
223
+ test('param obj !exist func str needs map to fn in locals or in params', function (done) {
224
+ var ast = {
225
+ inParams: ['a'],
226
+ tasks: [{ f: 'd.e', a: [], out: ['bar'], type: 'ret' }],
227
+ outTask: { a: ['bar'] },
228
+ locals: { }
229
+ };
230
+ t.deepEqual(validate(ast), []);
231
+ done();
232
+ });
233
+
234
+ test('multiple tasks output the same param, must be unique', function (done) {
235
+ var ast = {
236
+ inParams: ['a'],
237
+ tasks: [
238
+ { f: foo, a: [], out: ['baz', 'c'] },
239
+ { f: bar, a: [], out: ['c'] }
240
+ ],
241
+ outTask: { a: ['baz'] }
242
+ };
243
+ var msg = 'multiple tasks output the same param, must be unique. param: c';
244
+ t.deepEqual(validate(ast), [msg]);
245
+ done();
246
+ });
247
+
248
+ test('missing or mispelled input variable', function (done) {
249
+ var ast = {
250
+ inParams: [],
251
+ tasks: [
252
+ { f: foo, a: [], out: [] },
253
+ { f: bar, a: ['abc'], out: [] }
254
+ ],
255
+ outTask: { a: [] }
256
+ };
257
+ var msg = 'missing or mispelled variable referenced in flow definition: abc';
258
+ t.deepEqual(validate(ast), [msg]);
259
+ done();
260
+ });
261
+
262
+ test('missing or mispelled input variables', function (done) {
263
+ var ast = {
264
+ inParams: ['aaa', 'bbb'],
265
+ tasks: [
266
+ { f: foo, a: ['aaa', 'cat'], out: ['ccc'] },
267
+ { f: bar, a: ['abc', 'bbb', 'ccc'], out: [] }
268
+ ],
269
+ outTask: { a: [] }
270
+ };
271
+ var messages = [
272
+ 'missing or mispelled variable referenced in flow definition: cat',
273
+ 'missing or mispelled variable referenced in flow definition: abc'
274
+ ];
275
+ t.deepEqual(validate(ast), messages);
276
+ done();
277
+ });
278
+
279
+ test('missing or mispelled final output variables', function (done) {
280
+ var ast = {
281
+ inParams: ['aaa'],
282
+ tasks: [
283
+ { f: foo, a: ['aaa'], out: ['bbb'] },
284
+ { f: bar, a: ['bbb'], out: ['ccc'] }
285
+ ],
286
+ outTask: { a: ['ccc', 'ddd', 'eee'] }
287
+ };
288
+ var messages = [
289
+ 'missing or mispelled variable referenced in flow definition: ddd',
290
+ 'missing or mispelled variable referenced in flow definition: eee'
291
+ ];
292
+ t.deepEqual(validate(ast), messages);
293
+ done();
294
+ });
295
+
296
+ test('missing or mispelled validation ignores properties', function (done) {
297
+ var ast = {
298
+ inParams: ['obj'],
299
+ tasks: [
300
+ { f: foo, a: ['obj.foo'], out: [] },
301
+ { f: bar, a: ['obj.bar'], out: [] }
302
+ ],
303
+ outTask: { a: ['obj.cat'] }
304
+ };
305
+ t.deepEqual(validate(ast), []);
306
+ done();
307
+ });
308
+
309
+ test('missing or mispelled validation ignores literals', function (done) {
310
+ var ast = {
311
+ inParams: [],
312
+ tasks: [
313
+ { f: foo, a: ['true', 'false', '123', '123.1', 'null'], out: [] },
314
+ { f: bar, a: ['-123', '-123.4', '"wow"', "'hey'"], out: [] },
315
+ { f: foo, a: ['"two-words"', "'also-two'", '"two.words"', "'also.two'"], out: [] },
316
+ { f: foo, a: ['this'], out: [] }
317
+ ],
318
+ outTask: { a: [] }
319
+ };
320
+ t.deepEqual(validate(ast), []);
321
+ done();
322
+ });
323
+
324
+ }());
@@ -0,0 +1,193 @@
1
+ 'use strict';
2
+ /*global react:true VContext:true */
3
+
4
+ if (typeof(chai) === 'undefined') {
5
+ var chai = require('chai');
6
+ }
7
+
8
+ if (typeof(react) === 'undefined') {
9
+ var react = require('../'); //require('react');
10
+ }
11
+
12
+ if (typeof(VContext) === 'undefined') {
13
+ var VContext = require('../lib/vcon.js');
14
+ }
15
+
16
+ (function () {
17
+
18
+ var t = chai.assert;
19
+
20
+ /**
21
+ Testing Variable Context
22
+ */
23
+
24
+ suite('vcon');
25
+
26
+ test('VContext.create with empty args returns empty vCon', function (done) {
27
+ t.deepEqual(VContext.create([], []).values, {}, 'should be empty object');
28
+ t.deepEqual(VContext.create([], ['a']).values, {}, 'should be empty object');
29
+ done();
30
+ });
31
+
32
+ test('VContext.create with more args than params, ignore extra args', function (done) {
33
+ t.deepEqual(VContext.create([1], []).values, {}, 'should be empty object');
34
+ t.deepEqual(VContext.create([1, 2], ['a']).values, { a: 1 },
35
+ 'should be object with one value');
36
+ done();
37
+ });
38
+
39
+ test('VContext.create sets vCon[paramName] to arg value', function (done) {
40
+ t.deepEqual(VContext.create([1, 2], ['a', 'b']).values, { a: 1, b: 2 },
41
+ 'should have all values');
42
+ done();
43
+ });
44
+
45
+ test('create with locals is merged with args taking precedence', function (done) {
46
+ var locals = { a: 11, c: 30 };
47
+ t.deepEqual(VContext.create([1, 2], ['a', 'b'], locals).values,
48
+ { a: 1, c: 30, b: 2 }, 'should have merge of values');
49
+ done();
50
+ });
51
+
52
+ test('create with locals should not modify original locals', function (done) {
53
+ var locals = { a: 11, c: 30 };
54
+ t.deepEqual(VContext.create([1, 2], ['a', 'b'], locals).values,
55
+ { a: 1, c: 30, b: 2 }, 'should have merge of values');
56
+ t.deepEqual(locals, { a: 11, c: 30 }, 'should not modify original locals object');
57
+ done();
58
+ });
59
+
60
+ test('getVar on null returns null', function (done) {
61
+ t.equal(VContext.create([null], ['a']).getVar('a'), null);
62
+ t.equal(VContext.create([{ b: null }], ['a']).getVar('a.b'), null);
63
+ done();
64
+ });
65
+
66
+ test('getVar on undefined or null parent returns undefined', function (done) {
67
+ t.equal(VContext.create([], []).getVar('a'), undefined);
68
+ t.equal(VContext.create([], ['a']).getVar('a'), undefined);
69
+ t.equal(VContext.create([], ['a']).getVar('a.b'), undefined);
70
+ t.equal(VContext.create([], ['a']).getVar('a.b.c'), undefined);
71
+ t.equal(VContext.create([null], ['a']).getVar('a.b'), undefined);
72
+ t.equal(VContext.create([null], ['a']).getVar('a.b.c'), undefined);
73
+ t.equal(VContext.create([1], ['a']).getVar('a.b'), undefined);
74
+ t.equal(VContext.create([1], ['a']).getVar('a.b.c'), undefined);
75
+ done();
76
+ });
77
+
78
+ test('simple getVar returns existing value', function (done) {
79
+ t.equal(VContext.create([null], ['a']).getVar('a'), null);
80
+ t.equal(VContext.create([1], ['a']).getVar('a'), 1);
81
+ t.equal(VContext.create([true], ['a']).getVar('a'), true);
82
+ t.equal(VContext.create(['banana'], ['a']).getVar('a'), 'banana');
83
+ done();
84
+ });
85
+
86
+ test('getVar on literals returns the literal', function (done) {
87
+ t.equal(VContext.create([], []).getVar(true), true);
88
+ t.equal(VContext.create([], []).getVar(false), false);
89
+ t.equal(VContext.create([], []).getVar(null), null);
90
+ t.equal(VContext.create([], []).getVar('true'), true);
91
+ t.equal(VContext.create([], []).getVar('false'), false);
92
+ t.equal(VContext.create([], []).getVar('null'), null);
93
+ t.equal(VContext.create([], []).getVar(-100), -100);
94
+ t.equal(VContext.create([], []).getVar(100), 100);
95
+ t.equal(VContext.create([], []).getVar(123.4), 123.4);
96
+ t.equal(VContext.create([], []).getVar(-987.6), -987.6);
97
+ t.equal(VContext.create([], []).getVar('-100'), -100);
98
+ t.equal(VContext.create([], []).getVar('100'), 100);
99
+ t.equal(VContext.create([], []).getVar('123.4'), 123.4);
100
+ t.equal(VContext.create([], []).getVar('-987.6'), -987.6);
101
+ t.equal(VContext.create([], []).getVar('"foo"'), 'foo');
102
+ t.equal(VContext.create([], []).getVar("'foo'"), 'foo');
103
+ t.equal(VContext.create([], []).getVar("'foo.bar'"), 'foo.bar');
104
+ t.equal(VContext.create([], []).getVar("'foo-bar'"), 'foo-bar');
105
+ t.equal(VContext.create([], []).getVar("'foo-bar.json'"), 'foo-bar.json');
106
+ t.equal(VContext.create([], []).getVar('"foo-bar.json"'), 'foo-bar.json');
107
+ t.deepEqual(VContext.create([], [], null, { a: 1}).getVar('this'), { a: 1});
108
+ done();
109
+ });
110
+
111
+ test('getVar for property returns the property', function (done) {
112
+ var o = { b: 100};
113
+ t.equal(VContext.create([o], ['a']).getVar('a.b'), 100);
114
+ o = { b: { c: 200 }};
115
+ t.equal(VContext.create([o], ['a']).getVar('a.b.c'), 200);
116
+ done();
117
+ });
118
+
119
+ test('setVar will create objects if needed', function (done) {
120
+ var v = VContext.create([], []);
121
+ v.setVar('foo.bar.baz', 100);
122
+ t.deepEqual(v.values, { foo: { bar: { baz: 100}}});
123
+ done();
124
+ });
125
+
126
+ test('simple setVar', function (done) {
127
+ var v = VContext.create([], []);
128
+ v.setVar('foo', 100);
129
+ t.deepEqual(v.values, { foo: 100});
130
+ done();
131
+ });
132
+
133
+ test('setVar will not affect other vars', function (done) {
134
+ var v = VContext.create([{ bar: 1}], ['foo']);
135
+ v.setVar('foo.baz', 2);
136
+ t.deepEqual(v.values, { foo: { bar: 1, baz: 2 }});
137
+ done();
138
+ });
139
+
140
+ test('setVar with null key, will not set anything', function (done) {
141
+ var v = VContext.create([{ bar: 1}], ['foo']);
142
+ v.setVar(null, 2);
143
+ t.deepEqual(v.values, { foo: { bar: 1 }});
144
+ done();
145
+ });
146
+
147
+ test('setVar with undefined key, will not set anything', function (done) {
148
+ var v = VContext.create([{ bar: 1}], ['foo']);
149
+ v.setVar(undefined, 2);
150
+ t.deepEqual(v.values, { foo: { bar: 1 }});
151
+ done();
152
+ });
153
+
154
+ test('saveResults will set values for params and :LAST_RESULTS', function (done) {
155
+ var v = VContext.create([], []);
156
+ v.saveResults(['foo', 'bar', 'cat'], [1, 'hello', null]);
157
+ t.deepEqual(v.values, { foo: 1, bar: 'hello', cat: null,
158
+ ':LAST_RESULTS': [1, 'hello', null] });
159
+ done();
160
+ });
161
+
162
+ test('saveResults set :LAST_RESULT w/all even params is short', function (done) {
163
+ var v = VContext.create([], []);
164
+ v.saveResults(['foo'], [1, 'hello', null]);
165
+ t.deepEqual(v.values, { foo: 1,
166
+ ':LAST_RESULTS': [1, 'hello', null] });
167
+ done();
168
+ });
169
+
170
+ test('saveResults will set values for params and :LAST_RESULTS', function (done) {
171
+ var v = VContext.create([], []);
172
+ v.saveResults(['foo', 'bar', 'cat'], [1, 'hello', null]);
173
+ t.deepEqual(v.values, { foo: 1, bar: 'hello', cat: null,
174
+ ':LAST_RESULTS': [1, 'hello', null] });
175
+ done();
176
+ });
177
+
178
+ test('saveResults upgrades undefined to null, but :LAST_RESULT is exact', function (done) {
179
+ var v = VContext.create([], []);
180
+ v.saveResults(['foo', 'bar', 'baz'], [1, undefined]);
181
+ t.deepEqual(v.values, { foo: 1, bar: null, baz: null,
182
+ ':LAST_RESULTS': [1, undefined] });
183
+ done();
184
+ });
185
+
186
+ test('saveResults null params skips saving, :LAST_RESULT is exact', function (done) {
187
+ var v = VContext.create([], []);
188
+ v.saveResults(['foo', null], [1, 20]); //skip second param
189
+ t.deepEqual(v.values, { foo: 1, ':LAST_RESULTS': [1, 20] });
190
+ done();
191
+ });
192
+
193
+ }());