@@ -2,20 +2,39 @@ var module = QUnit.module;
2
2
var Enumerable = require ( '../linq' ) ;
3
3
require ( "../extensions/linq.qunit.js" ) ( { 'Enumerable' : Enumerable } ) ;
4
4
5
- if ( Enumerable . Utils . hasNativeIteratorSupport ( ) ) {
5
+ module ( "Iterator" ) ;
6
6
7
- module ( "Iterator" ) ;
7
+ var actual , expected ;
8
8
9
- var actual , expected ;
9
+ test ( "for..of" , function ( ) {
10
+ actual = [ ] ;
11
+ for ( var a of Enumerable . from ( [ 1 , 2 , 3 ] ) ) {
12
+ actual . push ( a ) ;
13
+ }
14
+ deepEqual ( actual , [ 1 , 2 , 3 ] ) ;
15
+ } ) ;
10
16
11
- test ( "for..of " , function ( )
12
- {
13
- actual = [ 1 , 2 , 3 , 4 ] ;
14
- expected = Array . from ( Enumerable . from ( actual ) ) ;
15
- deepEqual ( actual , expected ) ;
16
- var actual2 = actual . map ( function ( x ) { return x * 2 } ) ; // [2,4,6,8];
17
- expected = Enumerable . from ( actual ) . select ( function ( x ) { return x * 2 } ) ;
18
- deepEqual ( actual2 , Array . from ( expected ) ) ;
19
- } ) ;
17
+ test ( "Symbol.iterator " , function ( )
18
+ {
19
+ actual = [ 1 , 2 , 3 , 4 ] ;
20
+ expected = Array . from ( Enumerable . from ( actual ) ) ;
21
+ deepEqual ( actual , expected ) ;
22
+ var actual2 = actual . map ( function ( x ) { return x * 2 } ) ; // [2,4,6,8];
23
+ expected = Enumerable . from ( actual ) . select ( function ( x ) { return x * 2 } ) ;
24
+ deepEqual ( actual2 , Array . from ( expected ) ) ;
25
+ } ) ;
20
26
21
- }
27
+ test ( "from Iterable" , function ( ) {
28
+ function * words ( ) {
29
+ yield "abc" ;
30
+ yield "def" ;
31
+ }
32
+
33
+ deepEqual ( Enumerable . from ( words ( ) ) . toArray ( ) , [ "abc" , "def" ] ) ;
34
+
35
+ actual = [ ] ;
36
+ for ( var a of Enumerable . from ( words ( ) ) ) {
37
+ actual . push ( a ) ;
38
+ }
39
+ deepEqual ( actual , [ "abc" , "def" ] ) ;
40
+ } ) ;
0 commit comments