Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
rsvp.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
rsvp.js
Commits
2158a5a9
Commit
2158a5a9
authored
Jun 29, 2013
by
Stefan Penner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
put all extra tests in the same file. build tool quickfix
parent
c4c6e9d6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
47 deletions
+48
-47
test/tests/extension_test.js
test/tests/extension_test.js
+48
-0
test/tests/torture_test.js
test/tests/torture_test.js
+0
-47
No files found.
test/tests/extension_test.js
View file @
2158a5a9
...
...
@@ -978,3 +978,51 @@ describe("RSVP extensions", function() {
});
});
});
// thanks to @wizardwerdna for the test case -> https://github.com/tildeio/rsvp.js/issues/66
describe
(
"
using reduce to sum integers using promises
"
,
function
(){
var
resolve
=
RSVP
.
resolve
;
it
(
"
should build the promise pipeline without error
"
,
function
(){
var
array
,
iters
,
pZero
,
i
;
array
=
[];
iters
=
1000
;
for
(
i
=
1
;
i
<=
iters
;
i
++
)
{
array
.
push
(
i
);
}
pZero
=
resolve
(
0
);
array
.
reduce
(
function
(
promise
,
nextVal
)
{
return
promise
.
then
(
function
(
currentVal
)
{
return
resolve
(
currentVal
+
nextVal
);
});
},
pZero
);
});
it
(
"
should get correct answer without blowing the nextTick stack
"
,
function
(
done
){
var
pZero
,
array
,
iters
,
result
,
i
;
pZero
=
resolve
(
0
);
array
=
[];
iters
=
1000
;
for
(
i
=
1
;
i
<=
iters
;
i
++
)
{
array
.
push
(
i
);
}
result
=
array
.
reduce
(
function
(
promise
,
nextVal
)
{
return
promise
.
then
(
function
(
currentVal
)
{
return
resolve
(
currentVal
+
nextVal
);
});
},
pZero
);
result
.
then
(
function
(
value
){
assert
.
equal
(
value
,
(
iters
*
(
iters
+
1
)
/
2
));
done
();
});
});
});
test/tests/torture_test.js
deleted
100644 → 0
View file @
c4c6e9d6
// thanks to @wizardwerdna for the test case -> https://github.com/tildeio/rsvp.js/issues/66
describe
(
"
using reduce to sum integers using promises
"
,
function
(){
var
resolve
=
RSVP
.
resolve
;
it
(
"
should build the promise pipeline without error
"
,
function
(){
var
array
,
iters
,
pZero
,
i
;
array
=
[];
iters
=
1000
;
for
(
i
=
1
;
i
<=
iters
;
i
++
)
{
array
.
push
(
i
);
}
pZero
=
resolve
(
0
);
array
.
reduce
(
function
(
promise
,
nextVal
)
{
return
promise
.
then
(
function
(
currentVal
)
{
return
resolve
(
currentVal
+
nextVal
);
});
},
pZero
);
});
it
(
"
should get correct answer without blowing the nextTick stack
"
,
function
(
done
){
var
pZero
,
array
,
iters
,
result
,
i
;
pZero
=
resolve
(
0
);
array
=
[];
iters
=
1000
;
for
(
i
=
1
;
i
<=
iters
;
i
++
)
{
array
.
push
(
i
);
}
result
=
array
.
reduce
(
function
(
promise
,
nextVal
)
{
return
promise
.
then
(
function
(
currentVal
)
{
return
resolve
(
currentVal
+
nextVal
);
});
},
pZero
);
result
.
then
(
function
(
value
){
assert
.
equal
(
value
,
(
iters
*
(
iters
+
1
)
/
2
));
done
();
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment