SHOW:
|
|
- or go back to the newest paste.
| 1 | global.test1 = ''; | |
| 2 | ||
| 3 | app.get('/test1', function(req, res)
| |
| 4 | {
| |
| 5 | global.test1 = ''; | |
| 6 | global.test1 += '1'; | |
| 7 | global.test1 += '2'; | |
| 8 | global.test1 += '3'; | |
| 9 | global.test1 += '4'; | |
| 10 | global.test1 += '5'; | |
| 11 | ||
| 12 | if (global.test1 != '12345') | |
| 13 | {
| |
| 14 | console.log('not match: ' + global.test1);
| |
| 15 | } | |
| 16 | ||
| 17 | res.end(global.test1.toString()); | |
| 18 | }); | |
| 19 | ||
| 20 | global.test2 = ''; | |
| 21 | ||
| 22 | app.get('/test2', function(req, res)
| |
| 23 | {
| |
| 24 | global.test2 = ''; | |
| 25 | ||
| 26 | var i = 0; | |
| 27 | var interval; | |
| 28 | ||
| 29 | var append = function() | |
| 30 | {
| |
| 31 | i += 1; | |
| 32 | global.test2 += i.toString(); | |
| 33 | ||
| 34 | if (i == 10) | |
| 35 | {
| |
| 36 | clearInterval(interval); | |
| 37 | if (global.test2 != '12345678910') | |
| 38 | {
| |
| 39 | console.log('not match: ' + global.test2);
| |
| 40 | } | |
| 41 | ||
| 42 | res.end(global.test2); | |
| 43 | } | |
| 44 | }; | |
| 45 | ||
| 46 | interval = setInterval(append, 1); | |
| 47 | }); | |
| 48 | ||
| 49 | global.test4and5 = ''; | |
| 50 | ||
| 51 | app.get('/test4', function(req, res)
| |
| 52 | {
| |
| 53 | global.test4and5 = ''; | |
| 54 | global.test4and5 += '1'; | |
| 55 | global.test4and5 += '2'; | |
| 56 | global.test4and5 += '3'; | |
| 57 | global.test4and5 += '4'; | |
| 58 | global.test4and5 += '5'; | |
| 59 | ||
| 60 | if (global.test4and5 != '12345') | |
| 61 | {
| |
| 62 | console.log('not match: ' + global.test4and5);
| |
| 63 | } | |
| 64 | ||
| 65 | res.end(global.test4and5.toString()); | |
| 66 | }); | |
| 67 | ||
| 68 | app.get('/test5', function(req, res)
| |
| 69 | {
| |
| 70 | global.test4and5 = ''; | |
| 71 | ||
| 72 | global.test4and5 = ''; | |
| 73 | global.test4and5 += 'A'; | |
| 74 | global.test4and5 += 'B'; | |
| 75 | global.test4and5 += 'C'; | |
| 76 | global.test4and5 += 'D'; | |
| 77 | global.test4and5 += 'E'; | |
| 78 | ||
| 79 | if (global.test4and5 != 'ABCDE') | |
| 80 | {
| |
| 81 | console.log('not match: ' + global.test4and5);
| |
| 82 | } | |
| 83 | ||
| 84 | res.end(global.test4and5.toString()); | |
| 85 | }); |