scratch – Diff between revs 75 and 125

Subversion Repositories:
Rev:
Only display areas with differencesIgnore whitespace
Rev 75 Rev 125
1   1  
2 unless YAML? 2 unless YAML?
3 YAML = require '../../src/Yaml' 3 YAML = require '../../src/Yaml'
4   4  
5   5  
6 # Parsing 6 # Parsing
7 # 7 #
8   8  
9 describe 'Parsed YAML Collections', -> 9 describe 'Parsed YAML Collections', ->
10   10  
11 it 'can be simple sequence', -> 11 it 'can be simple sequence', ->
12   12  
13 expect YAML.parse """ 13 expect YAML.parse """
14 - apple 14 - apple
15 - banana 15 - banana
16 - carrot 16 - carrot
17 """ 17 """
18 .toEqual ['apple', 'banana', 'carrot'] 18 .toEqual ['apple', 'banana', 'carrot']
19   19  
20   20  
21 it 'can be nested sequences', -> 21 it 'can be nested sequences', ->
22   22  
23 expect YAML.parse """ 23 expect YAML.parse """
24 - 24 -
25 - foo 25 - foo
26 - bar 26 - bar
27 - baz 27 - baz
28 """ 28 """
29 .toEqual [['foo', 'bar', 'baz']] 29 .toEqual [['foo', 'bar', 'baz']]
30   30  
31   31  
32 it 'can be mixed sequences', -> 32 it 'can be mixed sequences', ->
33   33  
34 expect YAML.parse """ 34 expect YAML.parse """
35 - apple 35 - apple
36 - 36 -
37 - foo 37 - foo
38 - bar 38 - bar
39 - x123 39 - x123
40 - banana 40 - banana
41 - carrot 41 - carrot
42 """ 42 """
43 .toEqual ['apple', ['foo', 'bar', 'x123'], 'banana', 'carrot'] 43 .toEqual ['apple', ['foo', 'bar', 'x123'], 'banana', 'carrot']
44   44  
45   45  
46 it 'can be deeply nested sequences', -> 46 it 'can be deeply nested sequences', ->
47   47  
48 expect YAML.parse """ 48 expect YAML.parse """
49 - 49 -
50 - 50 -
51 - uno 51 - uno
52 - dos 52 - dos
53 """ 53 """
54 .toEqual [[['uno', 'dos']]] 54 .toEqual [[['uno', 'dos']]]
55   55  
56   56  
57 it 'can be simple mapping', -> 57 it 'can be simple mapping', ->
58   58  
59 expect YAML.parse """ 59 expect YAML.parse """
60 foo: whatever 60 foo: whatever
61 bar: stuff 61 bar: stuff
62 """ 62 """
63 .toEqual foo: 'whatever', bar: 'stuff' 63 .toEqual foo: 'whatever', bar: 'stuff'
64   64  
65   65  
66 it 'can be sequence in a mapping', -> 66 it 'can be sequence in a mapping', ->
67   67  
68 expect YAML.parse """ 68 expect YAML.parse """
69 foo: whatever 69 foo: whatever
70 bar: 70 bar:
71 - uno 71 - uno
72 - dos 72 - dos
73 """ 73 """
74 .toEqual foo: 'whatever', bar: ['uno', 'dos'] 74 .toEqual foo: 'whatever', bar: ['uno', 'dos']
75   75  
76   76  
77 it 'can be nested mappings', -> 77 it 'can be nested mappings', ->
78   78  
79 expect YAML.parse """ 79 expect YAML.parse """
80 foo: whatever 80 foo: whatever
81 bar: 81 bar:
82 fruit: apple 82 fruit: apple
83 name: steve 83 name: steve
84 sport: baseball 84 sport: baseball
85 """ 85 """
86 .toEqual foo: 'whatever', bar: (fruit: 'apple', name: 'steve', sport: 'baseball') 86 .toEqual foo: 'whatever', bar: (fruit: 'apple', name: 'steve', sport: 'baseball')
87   87  
88   88  
89 it 'can be mixed mapping', -> 89 it 'can be mixed mapping', ->
90   90  
91 expect YAML.parse """ 91 expect YAML.parse """
92 foo: whatever 92 foo: whatever
93 bar: 93 bar:
94 - 94 -
95 fruit: apple 95 fruit: apple
96 name: steve 96 name: steve
97 sport: baseball 97 sport: baseball
98 - more 98 - more
99 - 99 -
100 python: rocks 100 python: rocks
101 perl: papers 101 perl: papers
102 ruby: scissorses 102 ruby: scissorses
103 """ 103 """
104 .toEqual foo: 'whatever', bar: [ 104 .toEqual foo: 'whatever', bar: [
105 (fruit: 'apple', name: 'steve', sport: 'baseball'), 105 (fruit: 'apple', name: 'steve', sport: 'baseball'),
106 'more', 106 'more',
107 (python: 'rocks', perl: 'papers', ruby: 'scissorses') 107 (python: 'rocks', perl: 'papers', ruby: 'scissorses')
108 ] 108 ]
109   109  
110   110  
111 it 'can have mapping-in-sequence shortcut', -> 111 it 'can have mapping-in-sequence shortcut', ->
112   112  
113 expect YAML.parse """ 113 expect YAML.parse """
114 - work on YAML.py: 114 - work on YAML.py:
115 - work on Store 115 - work on Store
116 """ 116 """
117 .toEqual [('work on YAML.py': ['work on Store'])] 117 .toEqual [('work on YAML.py': ['work on Store'])]
118   118  
119   119  
120 it 'can have unindented sequence-in-mapping shortcut', -> 120 it 'can have unindented sequence-in-mapping shortcut', ->
121   121  
122 expect YAML.parse """ 122 expect YAML.parse """
123 allow: 123 allow:
124 - 'localhost' 124 - 'localhost'
125 - '%.sourceforge.net' 125 - '%.sourceforge.net'
126 - '%.freepan.org' 126 - '%.freepan.org'
127 """ 127 """
128 .toEqual (allow: ['localhost', '%.sourceforge.net', '%.freepan.org']) 128 .toEqual (allow: ['localhost', '%.sourceforge.net', '%.freepan.org'])
129   129  
130   130  
131 it 'can merge key', -> 131 it 'can merge key', ->
132   132  
133 expect YAML.parse """ 133 expect YAML.parse """
134 mapping: 134 mapping:
135 name: Joe 135 name: Joe
136 job: Accountant 136 job: Accountant
137 <<: 137 <<:
138 age: 38 138 age: 38
139 """ 139 """
140 .toEqual mapping: 140 .toEqual mapping:
141 name: 'Joe' 141 name: 'Joe'
142 job: 'Accountant' 142 job: 'Accountant'
143 age: 38 143 age: 38
144   144  
145 it 'can ignore trailing empty lines for smallest indent', -> 145 it 'can ignore trailing empty lines for smallest indent', ->
146   146  
147 expect YAML.parse """ trailing: empty lines\n""" 147 expect YAML.parse """ trailing: empty lines\n"""
148 .toEqual trailing: 'empty lines' 148 .toEqual trailing: 'empty lines'
149   149  
150 describe 'Parsed YAML Inline Collections', -> 150 describe 'Parsed YAML Inline Collections', ->
151   151  
152 it 'can be simple inline array', -> 152 it 'can be simple inline array', ->
153   153  
154 expect YAML.parse """ 154 expect YAML.parse """
155 --- 155 ---
156 seq: [ a, b, c ] 156 seq: [ a, b, c ]
157 """ 157 """
158 .toEqual seq: ['a', 'b', 'c'] 158 .toEqual seq: ['a', 'b', 'c']
159   159  
160   160  
161 it 'can be simple inline hash', -> 161 it 'can be simple inline hash', ->
162   162  
163 expect YAML.parse """ 163 expect YAML.parse """
164 --- 164 ---
165 hash: { name: Steve, foo: bar } 165 hash: { name: Steve, foo: bar }
166 """ 166 """
167 .toEqual hash: (name: 'Steve', foo: 'bar') 167 .toEqual hash: (name: 'Steve', foo: 'bar')
168   168  
169   169  
170 it 'can be nested inline hash', -> 170 it 'can be nested inline hash', ->
171   171  
172 expect YAML.parse """ 172 expect YAML.parse """
173 --- 173 ---
174 hash: { val1: "string", val2: { v2k1: "v2k1v" } } 174 hash: { val1: "string", val2: { v2k1: "v2k1v" } }
175 """ 175 """
176 .toEqual hash: (val1: 'string', val2: (v2k1: 'v2k1v')) 176 .toEqual hash: (val1: 'string', val2: (v2k1: 'v2k1v'))
177   177  
178   178  
179 it 'can be multi-line inline collections', -> 179 it 'can be multi-line inline collections', ->
180   180  
181 expect YAML.parse """ 181 expect YAML.parse """
182 languages: [ Ruby, 182 languages: [ Ruby,
183 Perl, 183 Perl,
184 Python ] 184 Python ]
185 websites: { YAML: yaml.org, 185 websites: { YAML: yaml.org,
186 Ruby: ruby-lang.org, 186 Ruby: ruby-lang.org,
187 Python: python.org, 187 Python: python.org,
188 Perl: use.perl.org } 188 Perl: use.perl.org }
189 """ 189 """
190 .toEqual ( 190 .toEqual (
191 languages: ['Ruby', 'Perl', 'Python'] 191 languages: ['Ruby', 'Perl', 'Python']
192 websites: 192 websites:
193 YAML: 'yaml.org' 193 YAML: 'yaml.org'
194 Ruby: 'ruby-lang.org' 194 Ruby: 'ruby-lang.org'
195 Python: 'python.org' 195 Python: 'python.org'
196 Perl: 'use.perl.org' 196 Perl: 'use.perl.org'
197 ) 197 )
198   198  
199   199  
200   200  
201 describe 'Parsed YAML Basic Types', -> 201 describe 'Parsed YAML Basic Types', ->
202   202  
203 it 'can be strings', -> 203 it 'can be strings', ->
204   204  
205 expect YAML.parse """ 205 expect YAML.parse """
206 --- 206 ---
207 String 207 String
208 """ 208 """
209 .toEqual 'String' 209 .toEqual 'String'
210   210  
211   211  
212 it 'can be double-quoted strings with backslashes', -> 212 it 'can be double-quoted strings with backslashes', ->
213   213  
214 expect YAML.parse """ 214 expect YAML.parse """
215 str: 215 str:
216 "string with \\\\ inside" 216 "string with \\\\ inside"
217 """ 217 """
218 .toEqual str: 'string with \\ inside' 218 .toEqual str: 'string with \\ inside'
219   219  
220   220  
221 it 'can be single-quoted strings with backslashes', -> 221 it 'can be single-quoted strings with backslashes', ->
222   222  
223 expect YAML.parse """ 223 expect YAML.parse """
224 str: 224 str:
225 'string with \\\\ inside' 225 'string with \\\\ inside'
226 """ 226 """
227 .toEqual str: 'string with \\\\ inside' 227 .toEqual str: 'string with \\\\ inside'
228   228  
229   229  
230 it 'can be double-quoted strings with line breaks', -> 230 it 'can be double-quoted strings with line breaks', ->
231   231  
232 expect YAML.parse """ 232 expect YAML.parse """
233 str: 233 str:
234 "string with \\n inside" 234 "string with \\n inside"
235 """ 235 """
236 .toEqual str: 'string with \n inside' 236 .toEqual str: 'string with \n inside'
237   237  
238   238  
239 it 'can be single-quoted strings with escaped line breaks', -> 239 it 'can be single-quoted strings with escaped line breaks', ->
240   240  
241 expect YAML.parse """ 241 expect YAML.parse """
242 str: 242 str:
243 'string with \\n inside' 243 'string with \\n inside'
244 """ 244 """
245 .toEqual str: 'string with \\n inside' 245 .toEqual str: 'string with \\n inside'
246   246  
247   247  
248 it 'can be double-quoted strings with line breaks and backslashes', -> 248 it 'can be double-quoted strings with line breaks and backslashes', ->
249   249  
250 expect YAML.parse """ 250 expect YAML.parse """
251 str: 251 str:
252 "string with \\n inside and \\\\ also" 252 "string with \\n inside and \\\\ also"
253 """ 253 """
254 .toEqual str: 'string with \n inside and \\ also' 254 .toEqual str: 'string with \n inside and \\ also'
255   255  
256   256  
257 it 'can be single-quoted strings with line breaks and backslashes', -> 257 it 'can be single-quoted strings with line breaks and backslashes', ->
258   258  
259 expect YAML.parse """ 259 expect YAML.parse """
260 str: 260 str:
261 'string with \\n inside and \\\\ also' 261 'string with \\n inside and \\\\ also'
262 """ 262 """
263 .toEqual str: 'string with \\n inside and \\\\ also' 263 .toEqual str: 'string with \\n inside and \\\\ also'
264   264  
265   265  
266 it 'can have string characters in sequences', -> 266 it 'can have string characters in sequences', ->
267   267  
268 expect YAML.parse """ 268 expect YAML.parse """
269 - What's Yaml? 269 - What's Yaml?
270 - It's for writing data structures in plain text. 270 - It's for writing data structures in plain text.
271 - And? 271 - And?
272 - And what? That's not good enough for you? 272 - And what? That's not good enough for you?
273 - No, I mean, "And what about Yaml?" 273 - No, I mean, "And what about Yaml?"
274 - Oh, oh yeah. Uh.. Yaml for JavaScript. 274 - Oh, oh yeah. Uh.. Yaml for JavaScript.
275 """ 275 """
276 .toEqual [ 276 .toEqual [
277 "What's Yaml?", 277 "What's Yaml?",
278 "It's for writing data structures in plain text.", 278 "It's for writing data structures in plain text.",
279 "And?", 279 "And?",
280 "And what? That's not good enough for you?", 280 "And what? That's not good enough for you?",
281 "No, I mean, \"And what about Yaml?\"", 281 "No, I mean, \"And what about Yaml?\"",
282 "Oh, oh yeah. Uh.. Yaml for JavaScript." 282 "Oh, oh yeah. Uh.. Yaml for JavaScript."
283 ] 283 ]
284   284  
285   285  
286 it 'can have indicators in strings', -> 286 it 'can have indicators in strings', ->
287   287  
288 expect YAML.parse """ 288 expect YAML.parse """
289 the colon followed by space is an indicator: but is a string:right here 289 the colon followed by space is an indicator: but is a string:right here
290 same for the pound sign: here we have it#in a string 290 same for the pound sign: here we have it#in a string
291 the comma can, honestly, be used in most cases: [ but not in, inline collections ] 291 the comma can, honestly, be used in most cases: [ but not in, inline collections ]
292 """ 292 """
293 .toEqual ( 293 .toEqual (
294 'the colon followed by space is an indicator': 'but is a string:right here', 294 'the colon followed by space is an indicator': 'but is a string:right here',
295 'same for the pound sign': 'here we have it#in a string', 295 'same for the pound sign': 'here we have it#in a string',
296 'the comma can, honestly, be used in most cases': ['but not in', 'inline collections'] 296 'the comma can, honestly, be used in most cases': ['but not in', 'inline collections']
297 ) 297 )
298   298  
299   299  
300 it 'can force strings', -> 300 it 'can force strings', ->
301   301  
302 expect YAML.parse """ 302 expect YAML.parse """
303 date string: !str 2001-08-01 303 date string: !str 2001-08-01
304 number string: !str 192 304 number string: !str 192
305 date string 2: !!str 2001-08-01 305 date string 2: !!str 2001-08-01
306 number string 2: !!str 192 306 number string 2: !!str 192
307 """ 307 """
308 .toEqual ( 308 .toEqual (
309 'date string': '2001-08-01', 309 'date string': '2001-08-01',
310 'number string': '192' , 310 'number string': '192' ,
311 'date string 2': '2001-08-01', 311 'date string 2': '2001-08-01',
312 'number string 2': '192' 312 'number string 2': '192'
313 ) 313 )
314   314  
315   315  
316 it 'can be single-quoted strings', -> 316 it 'can be single-quoted strings', ->
317   317  
318 expect YAML.parse """ 318 expect YAML.parse """
319 all my favorite symbols: '#:!/%.)' 319 all my favorite symbols: '#:!/%.)'
320 a few i hate: '&(*' 320 a few i hate: '&(*'
321 why do i hate them?: 'it''s very hard to explain' 321 why do i hate them?: 'it''s very hard to explain'
322 """ 322 """
323 .toEqual ( 323 .toEqual (
324 'all my favorite symbols': '#:!/%.)', 324 'all my favorite symbols': '#:!/%.)',
325 'a few i hate': '&(*', 325 'a few i hate': '&(*',
326 'why do i hate them?': 'it\'s very hard to explain' 326 'why do i hate them?': 'it\'s very hard to explain'
327 ) 327 )
328   328  
329   329  
330 it 'can be double-quoted strings', -> 330 it 'can be double-quoted strings', ->
331   331  
332 expect YAML.parse """ 332 expect YAML.parse """
333 i know where i want my line breaks: "one here\\nand another here\\n" 333 i know where i want my line breaks: "one here\\nand another here\\n"
334 """ 334 """
335 .toEqual ( 335 .toEqual (
336 'i know where i want my line breaks': "one here\nand another here\n" 336 'i know where i want my line breaks': "one here\nand another here\n"
337 ) 337 )
338   338  
339   339  
340 it 'can be null', -> 340 it 'can be null', ->
341   341  
342 expect YAML.parse """ 342 expect YAML.parse """
343 name: Mr. Show 343 name: Mr. Show
344 hosted by: Bob and David 344 hosted by: Bob and David
345 date of next season: ~ 345 date of next season: ~
346 """ 346 """
347 .toEqual ( 347 .toEqual (
348 'name': 'Mr. Show' 348 'name': 'Mr. Show'
349 'hosted by': 'Bob and David' 349 'hosted by': 'Bob and David'
350 'date of next season': null 350 'date of next season': null
351 ) 351 )
352   352  
353   353  
354 it 'can be boolean', -> 354 it 'can be boolean', ->
355   355  
356 expect YAML.parse """ 356 expect YAML.parse """
357 Is Gus a Liar?: true 357 Is Gus a Liar?: true
358 Do I rely on Gus for Sustenance?: false 358 Do I rely on Gus for Sustenance?: false
359 """ 359 """
360 .toEqual ( 360 .toEqual (
361 'Is Gus a Liar?': true 361 'Is Gus a Liar?': true
362 'Do I rely on Gus for Sustenance?': false 362 'Do I rely on Gus for Sustenance?': false
363 ) 363 )
364   364  
365   365  
366 it 'can be integers', -> 366 it 'can be integers', ->
367   367  
368 expect YAML.parse """ 368 expect YAML.parse """
369 zero: 0 369 zero: 0
370 simple: 12 370 simple: 12
371 one-thousand: 1,000 371 one-thousand: 1,000
372 negative one-thousand: -1,000 372 negative one-thousand: -1,000
373 """ 373 """
374 .toEqual ( 374 .toEqual (
375 'zero': 0 375 'zero': 0
376 'simple': 12 376 'simple': 12
377 'one-thousand': 1000 377 'one-thousand': 1000
378 'negative one-thousand': -1000 378 'negative one-thousand': -1000
379 ) 379 )
380   380  
381   381  
382 it 'can be integers as map keys', -> 382 it 'can be integers as map keys', ->
383   383  
384 expect YAML.parse """ 384 expect YAML.parse """
385 1: one 385 1: one
386 2: two 386 2: two
387 3: three 387 3: three
388 """ 388 """
389 .toEqual ( 389 .toEqual (
390 1: 'one' 390 1: 'one'
391 2: 'two' 391 2: 'two'
392 3: 'three' 392 3: 'three'
393 ) 393 )
394   394  
395   395  
396 it 'can be floats', -> 396 it 'can be floats', ->
397   397  
398 expect YAML.parse """ 398 expect YAML.parse """
399 a simple float: 2.00 399 a simple float: 2.00
400 larger float: 1,000.09 400 larger float: 1,000.09
401 scientific notation: 1.00009e+3 401 scientific notation: 1.00009e+3
402 """ 402 """
403 .toEqual ( 403 .toEqual (
404 'a simple float': 2.0 404 'a simple float': 2.0
405 'larger float': 1000.09 405 'larger float': 1000.09
406 'scientific notation': 1000.09 406 'scientific notation': 1000.09
407 ) 407 )
408   408  
409   409  
410 it 'can be time', -> 410 it 'can be time', ->
411   411  
412 iso8601Date = new Date Date.UTC(2001, 12-1, 14, 21, 59, 43, 10) 412 iso8601Date = new Date Date.UTC(2001, 12-1, 14, 21, 59, 43, 10)
413 iso8601Date.setTime iso8601Date.getTime() - 5 * 3600 * 1000 413 iso8601Date.setTime iso8601Date.getTime() - 5 * 3600 * 1000
414   414  
415 spaceSeparatedDate = new Date Date.UTC(2001, 12-1, 14, 21, 59, 43, 10) 415 spaceSeparatedDate = new Date Date.UTC(2001, 12-1, 14, 21, 59, 43, 10)
416 spaceSeparatedDate.setTime spaceSeparatedDate.getTime() - 5 * 3600 * 1000 416 spaceSeparatedDate.setTime spaceSeparatedDate.getTime() + 5 * 3600 * 1000
417   417  
418 withDatesToTime = (input) -> 418 withDatesToTime = (input) ->
419 res = {} 419 res = {}
420 for key, val of input 420 for key, val of input
421 res[key] = Math.round(val.getTime() / 1000) * 1000 421 res[key] = val.getTime()
422 return res 422 return res
423   423  
424 expect withDatesToTime(YAML.parse """ 424 expect withDatesToTime(YAML.parse """
425 iso8601: 2001-12-14t21:59:43.10-05:00 425 iso8601: 2001-12-14t21:59:43.010+05:00
426 space seperated: 2001-12-14 21:59:43.10 -05:00 426 space separated: 2001-12-14 21:59:43.010 -05:00
427 """) 427 """)
428 .toEqual withDatesToTime ( 428 .toEqual withDatesToTime (
429 'iso8601': iso8601Date 429 'iso8601': iso8601Date
430 'space seperated': spaceSeparatedDate 430 'space separated': spaceSeparatedDate
431 ) 431 )
432   432  
433   433  
434 it 'can be date', -> 434 it 'can be date', ->
435   435  
436 aDate = new Date Date.UTC(1976, 7-1, 31, 0, 0, 0, 0) 436 aDate = new Date Date.UTC(1976, 7-1, 31, 0, 0, 0, 0)
437   437  
438 withDatesToTime = (input) -> 438 withDatesToTime = (input) ->
439 return input 439 return input
440 res = {} 440 res = {}
441 for key, val of input 441 for key, val of input
442 res[key] = Math.round(val.getTime() / 1000) * 1000 442 res[key] = val.getTime()
443 return res 443 return res
444   444  
445 expect withDatesToTime(YAML.parse """ 445 expect withDatesToTime(YAML.parse """
446 date: 1976-07-31 446 date: 1976-07-31
447 """) 447 """)
448 .toEqual withDatesToTime ( 448 .toEqual withDatesToTime (
449 'date': aDate 449 'date': aDate
450 ) 450 )
451   451  
452   452  
453   453  
454 describe 'Parsed YAML Blocks', -> 454 describe 'Parsed YAML Blocks', ->
455   455  
456 it 'can be single ending newline', -> 456 it 'can be single ending newline', ->
457   457  
458 expect YAML.parse """ 458 expect YAML.parse """
459 --- 459 ---
460 this: | 460 this: |
461 Foo 461 Foo
462 Bar 462 Bar
463 """ 463 """
464 .toEqual 'this': "Foo\nBar\n" 464 .toEqual 'this': "Foo\nBar\n"
465   465  
466   466  
467 it 'can be single ending newline with \'+\' indicator', -> 467 it 'can be single ending newline with \'+\' indicator', ->
468   468  
469 expect YAML.parse """ 469 expect YAML.parse """
470 normal: | 470 normal: |
471 extra new lines not kept 471 extra new lines not kept
472   472  
473 preserving: |+ 473 preserving: |+
474 extra new lines are kept 474 extra new lines are kept
475   475  
476   476  
477 dummy: value 477 dummy: value
478 """ 478 """
479 .toEqual ( 479 .toEqual (
480 'normal': "extra new lines not kept\n" 480 'normal': "extra new lines not kept\n"
481 'preserving': "extra new lines are kept\n\n\n" 481 'preserving': "extra new lines are kept\n\n\n"
482 'dummy': 'value' 482 'dummy': 'value'
483 ) 483 )
484   484  
485   485  
486 it 'can be multi-line block handling trailing newlines in function of \'+\', \'-\' indicators', -> 486 it 'can be multi-line block handling trailing newlines in function of \'+\', \'-\' indicators', ->
487   487  
488 expect YAML.parse """ 488 expect YAML.parse """
489 clipped: | 489 clipped: |
490 This has one newline. 490 This has one newline.
491   491  
492   492  
493   493  
494 same as "clipped" above: "This has one newline.\\n" 494 same as "clipped" above: "This has one newline.\\n"
495   495  
496 stripped: |- 496 stripped: |-
497 This has no newline. 497 This has no newline.
498   498  
499   499  
500   500  
501 same as "stripped" above: "This has no newline." 501 same as "stripped" above: "This has no newline."
502   502  
503 kept: |+ 503 kept: |+
504 This has four newlines. 504 This has four newlines.
505   505  
506   506  
507   507  
508 same as "kept" above: "This has four newlines.\\n\\n\\n\\n" 508 same as "kept" above: "This has four newlines.\\n\\n\\n\\n"
509 """ 509 """
510 .toEqual ( 510 .toEqual (
511 'clipped': "This has one newline.\n" 511 'clipped': "This has one newline.\n"
512 'same as "clipped" above': "This has one newline.\n" 512 'same as "clipped" above': "This has one newline.\n"
513 'stripped':'This has no newline.' 513 'stripped':'This has no newline.'
514 'same as "stripped" above': 'This has no newline.' 514 'same as "stripped" above': 'This has no newline.'
515 'kept': "This has four newlines.\n\n\n\n" 515 'kept': "This has four newlines.\n\n\n\n"
516 'same as "kept" above': "This has four newlines.\n\n\n\n" 516 'same as "kept" above': "This has four newlines.\n\n\n\n"
517 ) 517 )
518   518  
519   519  
520 it 'can be folded block in a sequence', -> 520 it 'can be folded block in a sequence', ->
521   521  
522 expect YAML.parse """ 522 expect YAML.parse """
523 --- 523 ---
524 - apple 524 - apple
525 - banana 525 - banana
526 - > 526 - >
527 can't you see 527 can't you see
528 the beauty of yaml? 528 the beauty of yaml?
529 hmm 529 hmm
530 - dog 530 - dog
531 """ 531 """
532 .toEqual [ 532 .toEqual [
533 'apple', 533 'apple',
534 'banana', 534 'banana',
535 "can't you see the beauty of yaml? hmm\n", 535 "can't you see the beauty of yaml? hmm\n",
536 'dog' 536 'dog'
537 ] 537 ]
538   538  
539   539  
540 it 'can be folded block as a mapping value', -> 540 it 'can be folded block as a mapping value', ->
541   541  
542 expect YAML.parse """ 542 expect YAML.parse """
543 --- 543 ---
544 quote: > 544 quote: >
545 Mark McGwire's 545 Mark McGwire's
546 year was crippled 546 year was crippled
547 by a knee injury. 547 by a knee injury.
548 source: espn 548 source: espn
549 """ 549 """
550 .toEqual ( 550 .toEqual (
551 'quote': "Mark McGwire's year was crippled by a knee injury.\n" 551 'quote': "Mark McGwire's year was crippled by a knee injury.\n"
552 'source': 'espn' 552 'source': 'espn'
553 ) 553 )
554   554  
555   555  
556 it 'can be folded block handling trailing newlines in function of \'+\', \'-\' indicators', -> 556 it 'can be folded block handling trailing newlines in function of \'+\', \'-\' indicators', ->
557   557  
558 expect YAML.parse """ 558 expect YAML.parse """
559 clipped: > 559 clipped: >
560 This has one newline. 560 This has one newline.
561   561  
562   562  
563   563  
564 same as "clipped" above: "This has one newline.\\n" 564 same as "clipped" above: "This has one newline.\\n"
565   565  
566 stripped: >- 566 stripped: >-
567 This has no newline. 567 This has no newline.
568   568  
569   569  
570   570  
571 same as "stripped" above: "This has no newline." 571 same as "stripped" above: "This has no newline."
572   572  
573 kept: >+ 573 kept: >+
574 This has four newlines. 574 This has four newlines.
575   575  
576   576  
577   577  
578 same as "kept" above: "This has four newlines.\\n\\n\\n\\n" 578 same as "kept" above: "This has four newlines.\\n\\n\\n\\n"
579 """ 579 """
580 .toEqual ( 580 .toEqual (
581 'clipped': "This has one newline.\n" 581 'clipped': "This has one newline.\n"
582 'same as "clipped" above': "This has one newline.\n" 582 'same as "clipped" above': "This has one newline.\n"
583 'stripped': 'This has no newline.' 583 'stripped': 'This has no newline.'
584 'same as "stripped" above': 'This has no newline.' 584 'same as "stripped" above': 'This has no newline.'
585 'kept': "This has four newlines.\n\n\n\n" 585 'kept': "This has four newlines.\n\n\n\n"
586 'same as "kept" above': "This has four newlines.\n\n\n\n" 586 'same as "kept" above': "This has four newlines.\n\n\n\n"
587 ) 587 )
588   588  
589   589  
590 it 'can be the whole document as intented block', -> 590 it 'can be the whole document as intented block', ->
591   591  
592 expect YAML.parse """ 592 expect YAML.parse """
593 --- 593 ---
594 foo: "bar" 594 foo: "bar"
595 baz: 595 baz:
596 - "qux" 596 - "qux"
597 - "quxx" 597 - "quxx"
598 corge: null 598 corge: null
599 """ 599 """
600 .toEqual ( 600 .toEqual (
601 'foo': "bar" 601 'foo': "bar"
602 'baz': ['qux', 'quxx'] 602 'baz': ['qux', 'quxx']
603 'corge': null 603 'corge': null
604 ) 604 )
605   605  
606   606  
607   607  
608   608  
609 describe 'Parsed YAML Comments', -> 609 describe 'Parsed YAML Comments', ->
610   610  
611 it 'can begin the document', -> 611 it 'can begin the document', ->
612   612  
613 expect YAML.parse """ 613 expect YAML.parse """
614 # This is a comment 614 # This is a comment
615 hello: world 615 hello: world
616 """ 616 """
617 .toEqual ( 617 .toEqual (
618 hello: 'world' 618 hello: 'world'
619 ) 619 )
620   620  
621   621  
622 it 'can be less indented in mapping', -> 622 it 'can be less indented in mapping', ->
623   623  
624 expect YAML.parse """ 624 expect YAML.parse """
625 parts: 625 parts:
626 a: 'b' 626 a: 'b'
627 # normally indented comment 627 # normally indented comment
628 c: 'd' 628 c: 'd'
629 # less indented comment 629 # less indented comment
630 e: 'f' 630 e: 'f'
631 """ 631 """
632 .toEqual ( 632 .toEqual (
633 parts: {a: 'b', c: 'd', e: 'f'} 633 parts: {a: 'b', c: 'd', e: 'f'}
634 ) 634 )
635   635  
636   636  
637 it 'can be less indented in sequence', -> 637 it 'can be less indented in sequence', ->
638   638  
639 expect YAML.parse """ 639 expect YAML.parse """
640 list-header: 640 list-header:
641 - item1 641 - item1
642 # - item2 642 # - item2
643 - item3 643 - item3
644 # - item4 644 # - item4
645 """ 645 """
646 .toEqual ( 646 .toEqual (
647 'list-header': ['item1', 'item3'] 647 'list-header': ['item1', 'item3']
648 ) 648 )
649   649  
650   650  
651 it 'can finish a line', -> 651 it 'can finish a line', ->
652   652  
653 expect YAML.parse """ 653 expect YAML.parse """
654 hello: world # This is a comment 654 hello: world # This is a comment
655 """ 655 """
656 .toEqual ( 656 .toEqual (
657 hello: 'world' 657 hello: 'world'
658 ) 658 )
659   659  
660   660  
661 it 'can end the document', -> 661 it 'can end the document', ->
662   662  
663 expect YAML.parse """ 663 expect YAML.parse """
664 hello: world 664 hello: world
665 # This is a comment 665 # This is a comment
666 """ 666 """
667 .toEqual ( 667 .toEqual (
668 hello: 'world' 668 hello: 'world'
669 ) 669 )
670   670  
671   671  
672   672  
673 describe 'Parsed YAML Aliases and Anchors', -> 673 describe 'Parsed YAML Aliases and Anchors', ->
674   674  
675 it 'can be simple alias', -> 675 it 'can be simple alias', ->
676   676  
677 expect YAML.parse """ 677 expect YAML.parse """
678 - &showell Steve 678 - &showell Steve
679 - Clark 679 - Clark
680 - Brian 680 - Brian
681 - Oren 681 - Oren
682 - *showell 682 - *showell
683 """ 683 """
684 .toEqual ['Steve', 'Clark', 'Brian', 'Oren', 'Steve'] 684 .toEqual ['Steve', 'Clark', 'Brian', 'Oren', 'Steve']
685   685  
686   686  
687 it 'can be alias of a mapping', -> 687 it 'can be alias of a mapping', ->
688   688  
689 expect YAML.parse """ 689 expect YAML.parse """
690 - &hello 690 - &hello
691 Meat: pork 691 Meat: pork
692 Starch: potato 692 Starch: potato
693 - banana 693 - banana
694 - *hello 694 - *hello
695 """ 695 """
696 .toEqual [ 696 .toEqual [
697 Meat: 'pork', Starch: 'potato' 697 Meat: 'pork', Starch: 'potato'
698 , 698 ,
699 'banana' 699 'banana'
700 , 700 ,
701 Meat: 'pork', Starch: 'potato' 701 Meat: 'pork', Starch: 'potato'
702 ] 702 ]
703   703  
704   704  
705   705  
706 describe 'Parsed YAML Documents', -> 706 describe 'Parsed YAML Documents', ->
707   707  
708 it 'can have YAML header', -> 708 it 'can have YAML header', ->
709   709  
710 expect YAML.parse """ 710 expect YAML.parse """
711 --- %YAML:1.0 711 --- %YAML:1.0
712 foo: 1 712 foo: 1
713 bar: 2 713 bar: 2
714 """ 714 """
715 .toEqual ( 715 .toEqual (
716 foo: 1 716 foo: 1
717 bar: 2 717 bar: 2
718 ) 718 )
719   719  
720   720  
721 it 'can have leading document separator', -> 721 it 'can have leading document separator', ->
722   722  
723 expect YAML.parse """ 723 expect YAML.parse """
724 --- 724 ---
725 - foo: 1 725 - foo: 1
726 bar: 2 726 bar: 2
727 """ 727 """
728 .toEqual [( 728 .toEqual [(
729 foo: 1 729 foo: 1
730 bar: 2 730 bar: 2
731 )] 731 )]
732   732  
733   733  
734 it 'can have multiple document separators in block', -> 734 it 'can have multiple document separators in block', ->
735   735  
736 expect YAML.parse """ 736 expect YAML.parse """
737 foo: | 737 foo: |
738 --- 738 ---
739 foo: bar 739 foo: bar
740 --- 740 ---
741 yo: baz 741 yo: baz
742 bar: | 742 bar: |
743 fooness 743 fooness
744 """ 744 """
745 .toEqual ( 745 .toEqual (
746 foo: "---\nfoo: bar\n---\nyo: baz\n" 746 foo: "---\nfoo: bar\n---\nyo: baz\n"
747 bar: "fooness\n" 747 bar: "fooness\n"
748 ) 748 )
749   749  
750   750  
751 # Dumping 751 # Dumping
752 # 752 #
753   753  
754 describe 'Dumped YAML Collections', -> 754 describe 'Dumped YAML Collections', ->
755   755  
756 it 'can be simple sequence', -> 756 it 'can be simple sequence', ->
757   757  
758 expect YAML.parse """ 758 expect YAML.parse """
759 - apple 759 - apple
760 - banana 760 - banana
761 - carrot 761 - carrot
762 """ 762 """
763 .toEqual YAML.parse YAML.dump ['apple', 'banana', 'carrot'] 763 .toEqual YAML.parse YAML.dump ['apple', 'banana', 'carrot']
764   764  
765   765  
766 it 'can be nested sequences', -> 766 it 'can be nested sequences', ->
767   767  
768 expect YAML.parse """ 768 expect YAML.parse """
769 - 769 -
770 - foo 770 - foo
771 - bar 771 - bar
772 - baz 772 - baz
773 """ 773 """
774 .toEqual YAML.parse YAML.dump [['foo', 'bar', 'baz']] 774 .toEqual YAML.parse YAML.dump [['foo', 'bar', 'baz']]
775   775  
776   776  
777 it 'can be mixed sequences', -> 777 it 'can be mixed sequences', ->
778   778  
779 expect YAML.parse """ 779 expect YAML.parse """
780 - apple 780 - apple
781 - 781 -
782 - foo 782 - foo
783 - bar 783 - bar
784 - x123 784 - x123
785 - banana 785 - banana
786 - carrot 786 - carrot
787 """ 787 """
788 .toEqual YAML.parse YAML.dump ['apple', ['foo', 'bar', 'x123'], 'banana', 'carrot'] 788 .toEqual YAML.parse YAML.dump ['apple', ['foo', 'bar', 'x123'], 'banana', 'carrot']
789   789  
790   790  
791 it 'can be deeply nested sequences', -> 791 it 'can be deeply nested sequences', ->
792   792  
793 expect YAML.parse """ 793 expect YAML.parse """
794 - 794 -
795 - 795 -
796 - uno 796 - uno
797 - dos 797 - dos
798 """ 798 """
799 .toEqual YAML.parse YAML.dump [[['uno', 'dos']]] 799 .toEqual YAML.parse YAML.dump [[['uno', 'dos']]]
800   800  
801   801  
802 it 'can be simple mapping', -> 802 it 'can be simple mapping', ->
803   803  
804 expect YAML.parse """ 804 expect YAML.parse """
805 foo: whatever 805 foo: whatever
806 bar: stuff 806 bar: stuff
807 """ 807 """
808 .toEqual YAML.parse YAML.dump foo: 'whatever', bar: 'stuff' 808 .toEqual YAML.parse YAML.dump foo: 'whatever', bar: 'stuff'
809   809  
810   810  
811 it 'can be sequence in a mapping', -> 811 it 'can be sequence in a mapping', ->
812   812  
813 expect YAML.parse """ 813 expect YAML.parse """
814 foo: whatever 814 foo: whatever
815 bar: 815 bar:
816 - uno 816 - uno
817 - dos 817 - dos
818 """ 818 """
819 .toEqual YAML.parse YAML.dump foo: 'whatever', bar: ['uno', 'dos'] 819 .toEqual YAML.parse YAML.dump foo: 'whatever', bar: ['uno', 'dos']
820   820  
821   821  
822 it 'can be nested mappings', -> 822 it 'can be nested mappings', ->
823   823  
824 expect YAML.parse """ 824 expect YAML.parse """
825 foo: whatever 825 foo: whatever
826 bar: 826 bar:
827 fruit: apple 827 fruit: apple
828 name: steve 828 name: steve
829 sport: baseball 829 sport: baseball
830 """ 830 """
831 .toEqual YAML.parse YAML.dump foo: 'whatever', bar: (fruit: 'apple', name: 'steve', sport: 'baseball') 831 .toEqual YAML.parse YAML.dump foo: 'whatever', bar: (fruit: 'apple', name: 'steve', sport: 'baseball')
832   832  
833   833  
834 it 'can be mixed mapping', -> 834 it 'can be mixed mapping', ->
835   835  
836 expect YAML.parse """ 836 expect YAML.parse """
837 foo: whatever 837 foo: whatever
838 bar: 838 bar:
839 - 839 -
840 fruit: apple 840 fruit: apple
841 name: steve 841 name: steve
842 sport: baseball 842 sport: baseball
843 - more 843 - more
844 - 844 -
845 python: rocks 845 python: rocks
846 perl: papers 846 perl: papers
847 ruby: scissorses 847 ruby: scissorses
848 """ 848 """
849 .toEqual YAML.parse YAML.dump foo: 'whatever', bar: [ 849 .toEqual YAML.parse YAML.dump foo: 'whatever', bar: [
850 (fruit: 'apple', name: 'steve', sport: 'baseball'), 850 (fruit: 'apple', name: 'steve', sport: 'baseball'),
851 'more', 851 'more',
852 (python: 'rocks', perl: 'papers', ruby: 'scissorses') 852 (python: 'rocks', perl: 'papers', ruby: 'scissorses')
853 ] 853 ]
854   854  
855   855  
856 it 'can have mapping-in-sequence shortcut', -> 856 it 'can have mapping-in-sequence shortcut', ->
857   857  
858 expect YAML.parse """ 858 expect YAML.parse """
859 - work on YAML.py: 859 - work on YAML.py:
860 - work on Store 860 - work on Store
861 """ 861 """
862 .toEqual YAML.parse YAML.dump [('work on YAML.py': ['work on Store'])] 862 .toEqual YAML.parse YAML.dump [('work on YAML.py': ['work on Store'])]
863   863  
864   864  
865 it 'can have unindented sequence-in-mapping shortcut', -> 865 it 'can have unindented sequence-in-mapping shortcut', ->
866   866  
867 expect YAML.parse """ 867 expect YAML.parse """
868 allow: 868 allow:
869 - 'localhost' 869 - 'localhost'
870 - '%.sourceforge.net' 870 - '%.sourceforge.net'
871 - '%.freepan.org' 871 - '%.freepan.org'
872 """ 872 """
873 .toEqual YAML.parse YAML.dump (allow: ['localhost', '%.sourceforge.net', '%.freepan.org']) 873 .toEqual YAML.parse YAML.dump (allow: ['localhost', '%.sourceforge.net', '%.freepan.org'])
874   874  
875   875  
876 it 'can merge key', -> 876 it 'can merge key', ->
877   877  
878 expect YAML.parse """ 878 expect YAML.parse """
879 mapping: 879 mapping:
880 name: Joe 880 name: Joe
881 job: Accountant 881 job: Accountant
882 <<: 882 <<:
883 age: 38 883 age: 38
884 """ 884 """
885 .toEqual YAML.parse YAML.dump mapping: 885 .toEqual YAML.parse YAML.dump mapping:
886 name: 'Joe' 886 name: 'Joe'
887 job: 'Accountant' 887 job: 'Accountant'
888 age: 38 888 age: 38
889   889  
890   890  
891   891  
892 describe 'Dumped YAML Inline Collections', -> 892 describe 'Dumped YAML Inline Collections', ->
893   893  
894 it 'can be simple inline array', -> 894 it 'can be simple inline array', ->
895   895  
896 expect YAML.parse """ 896 expect YAML.parse """
897 --- 897 ---
898 seq: [ a, b, c ] 898 seq: [ a, b, c ]
899 """ 899 """
900 .toEqual YAML.parse YAML.dump seq: ['a', 'b', 'c'] 900 .toEqual YAML.parse YAML.dump seq: ['a', 'b', 'c']
901   901  
902   902  
903 it 'can be simple inline hash', -> 903 it 'can be simple inline hash', ->
904   904  
905 expect YAML.parse """ 905 expect YAML.parse """
906 --- 906 ---
907 hash: { name: Steve, foo: bar } 907 hash: { name: Steve, foo: bar }
908 """ 908 """
909 .toEqual YAML.parse YAML.dump hash: (name: 'Steve', foo: 'bar') 909 .toEqual YAML.parse YAML.dump hash: (name: 'Steve', foo: 'bar')
910   910  
911   911  
912 it 'can be multi-line inline collections', -> 912 it 'can be multi-line inline collections', ->
913   913  
914 expect YAML.parse """ 914 expect YAML.parse """
915 languages: [ Ruby, 915 languages: [ Ruby,
916 Perl, 916 Perl,
917 Python ] 917 Python ]
918 websites: { YAML: yaml.org, 918 websites: { YAML: yaml.org,
919 Ruby: ruby-lang.org, 919 Ruby: ruby-lang.org,
920 Python: python.org, 920 Python: python.org,
921 Perl: use.perl.org } 921 Perl: use.perl.org }
922 """ 922 """
923 .toEqual YAML.parse YAML.dump ( 923 .toEqual YAML.parse YAML.dump (
924 languages: ['Ruby', 'Perl', 'Python'] 924 languages: ['Ruby', 'Perl', 'Python']
925 websites: 925 websites:
926 YAML: 'yaml.org' 926 YAML: 'yaml.org'
927 Ruby: 'ruby-lang.org' 927 Ruby: 'ruby-lang.org'
928 Python: 'python.org' 928 Python: 'python.org'
929 Perl: 'use.perl.org' 929 Perl: 'use.perl.org'
930 ) 930 )
931   931  
932 it 'can be dumped empty sequences in mappings', -> 932 it 'can be dumped empty sequences in mappings', ->
933   933  
934 expect YAML.parse(YAML.dump({key:[]})) 934 expect YAML.parse(YAML.dump({key:[]}))
935 .toEqual({key:[]}) 935 .toEqual({key:[]})
-   936  
-   937 it 'can be dumpted empty inline collections', ->
-   938  
936   939 expect YAML.parse(YAML.dump({key:{}}))
937   940 .toEqual({key:{}})
938   941  
939 describe 'Dumped YAML Basic Types', -> 942 describe 'Dumped YAML Basic Types', ->
940   943  
941 it 'can be strings', -> 944 it 'can be strings', ->
942   945  
943 expect YAML.parse """ 946 expect YAML.parse """
944 --- 947 ---
945 String 948 String
946 """ 949 """
947 .toEqual YAML.parse YAML.dump 'String' 950 .toEqual YAML.parse YAML.dump 'String'
948   951  
949   952  
950 it 'can be double-quoted strings with backslashes', -> 953 it 'can be double-quoted strings with backslashes', ->
951   954  
952 expect YAML.parse """ 955 expect YAML.parse """
953 str: 956 str:
954 "string with \\\\ inside" 957 "string with \\\\ inside"
955 """ 958 """
956 .toEqual YAML.parse YAML.dump str: 'string with \\ inside' 959 .toEqual YAML.parse YAML.dump str: 'string with \\ inside'
957   960  
958   961  
959 it 'can be single-quoted strings with backslashes', -> 962 it 'can be single-quoted strings with backslashes', ->
960   963  
961 expect YAML.parse """ 964 expect YAML.parse """
962 str: 965 str:
963 'string with \\\\ inside' 966 'string with \\\\ inside'
964 """ 967 """
965 .toEqual YAML.parse YAML.dump str: 'string with \\\\ inside' 968 .toEqual YAML.parse YAML.dump str: 'string with \\\\ inside'
966   969  
967   970  
968 it 'can be double-quoted strings with line breaks', -> 971 it 'can be double-quoted strings with line breaks', ->
969   972  
970 expect YAML.parse """ 973 expect YAML.parse """
971 str: 974 str:
972 "string with \\n inside" 975 "string with \\n inside"
973 """ 976 """
974 .toEqual YAML.parse YAML.dump str: 'string with \n inside' 977 .toEqual YAML.parse YAML.dump str: 'string with \n inside'
975   978  
976   979  
977 it 'can be double-quoted strings with line breaks and backslashes', -> 980 it 'can be double-quoted strings with line breaks and backslashes', ->
978   981  
979 expect YAML.parse """ 982 expect YAML.parse """
980 str: 983 str:
981 "string with \\n inside and \\\\ also" 984 "string with \\n inside and \\\\ also"
982 """ 985 """
983 .toEqual YAML.parse YAML.dump str: 'string with \n inside and \\ also' 986 .toEqual YAML.parse YAML.dump str: 'string with \n inside and \\ also'
984   987  
985   988  
986 it 'can be single-quoted strings with line breaks and backslashes', -> 989 it 'can be single-quoted strings with line breaks and backslashes', ->
987   990  
988 expect YAML.parse """ 991 expect YAML.parse """
989 str: 992 str:
990 'string with \\n inside and \\\\ also' 993 'string with \\n inside and \\\\ also'
991 """ 994 """
992 .toEqual YAML.parse YAML.dump str: 'string with \\n inside and \\\\ also' 995 .toEqual YAML.parse YAML.dump str: 'string with \\n inside and \\\\ also'
993   996  
994   997  
995 it 'can be single-quoted strings with escaped line breaks', -> 998 it 'can be single-quoted strings with escaped line breaks', ->
996   999  
997 expect YAML.parse """ 1000 expect YAML.parse """
998 str: 1001 str:
999 'string with \\n inside' 1002 'string with \\n inside'
1000 """ 1003 """
1001 .toEqual YAML.parse YAML.dump str: 'string with \\n inside' 1004 .toEqual YAML.parse YAML.dump str: 'string with \\n inside'
1002   1005  
1003   1006  
1004 it 'can have string characters in sequences', -> 1007 it 'can have string characters in sequences', ->
1005   1008  
1006 expect YAML.parse """ 1009 expect YAML.parse """
1007 - What's Yaml? 1010 - What's Yaml?
1008 - It's for writing data structures in plain text. 1011 - It's for writing data structures in plain text.
1009 - And? 1012 - And?
1010 - And what? That's not good enough for you? 1013 - And what? That's not good enough for you?
1011 - No, I mean, "And what about Yaml?" 1014 - No, I mean, "And what about Yaml?"
1012 - Oh, oh yeah. Uh.. Yaml for JavaScript. 1015 - Oh, oh yeah. Uh.. Yaml for JavaScript.
1013 """ 1016 """
1014 .toEqual YAML.parse YAML.dump [ 1017 .toEqual YAML.parse YAML.dump [
1015 "What's Yaml?", 1018 "What's Yaml?",
1016 "It's for writing data structures in plain text.", 1019 "It's for writing data structures in plain text.",
1017 "And?", 1020 "And?",
1018 "And what? That's not good enough for you?", 1021 "And what? That's not good enough for you?",
1019 "No, I mean, \"And what about Yaml?\"", 1022 "No, I mean, \"And what about Yaml?\"",
1020 "Oh, oh yeah. Uh.. Yaml for JavaScript." 1023 "Oh, oh yeah. Uh.. Yaml for JavaScript."
1021 ] 1024 ]
1022   1025  
1023   1026  
1024 it 'can have indicators in strings', -> 1027 it 'can have indicators in strings', ->
1025   1028  
1026 expect YAML.parse """ 1029 expect YAML.parse """
1027 the colon followed by space is an indicator: but is a string:right here 1030 the colon followed by space is an indicator: but is a string:right here
1028 same for the pound sign: here we have it#in a string 1031 same for the pound sign: here we have it#in a string
1029 the comma can, honestly, be used in most cases: [ but not in, inline collections ] 1032 the comma can, honestly, be used in most cases: [ but not in, inline collections ]
1030 """ 1033 """
1031 .toEqual YAML.parse YAML.dump ( 1034 .toEqual YAML.parse YAML.dump (
1032 'the colon followed by space is an indicator': 'but is a string:right here', 1035 'the colon followed by space is an indicator': 'but is a string:right here',
1033 'same for the pound sign': 'here we have it#in a string', 1036 'same for the pound sign': 'here we have it#in a string',
1034 'the comma can, honestly, be used in most cases': ['but not in', 'inline collections'] 1037 'the comma can, honestly, be used in most cases': ['but not in', 'inline collections']
1035 ) 1038 )
1036   1039  
1037   1040  
1038 it 'can force strings', -> 1041 it 'can force strings', ->
1039   1042  
1040 expect YAML.parse """ 1043 expect YAML.parse """
1041 date string: !str 2001-08-01 1044 date string: !str 2001-08-01
1042 number string: !str 192 1045 number string: !str 192
1043 date string 2: !!str 2001-08-01 1046 date string 2: !!str 2001-08-01
1044 number string 2: !!str 192 1047 number string 2: !!str 192
1045 """ 1048 """
1046 .toEqual YAML.parse YAML.dump ( 1049 .toEqual YAML.parse YAML.dump (
1047 'date string': '2001-08-01', 1050 'date string': '2001-08-01',
1048 'number string': '192' , 1051 'number string': '192' ,
1049 'date string 2': '2001-08-01', 1052 'date string 2': '2001-08-01',
1050 'number string 2': '192' 1053 'number string 2': '192'
1051 ) 1054 )
1052   1055  
1053   1056  
1054 it 'can be single-quoted strings', -> 1057 it 'can be single-quoted strings', ->
1055   1058  
1056 expect YAML.parse """ 1059 expect YAML.parse """
1057 all my favorite symbols: '#:!/%.)' 1060 all my favorite symbols: '#:!/%.)'
1058 a few i hate: '&(*' 1061 a few i hate: '&(*'
1059 why do i hate them?: 'it''s very hard to explain' 1062 why do i hate them?: 'it''s very hard to explain'
1060 """ 1063 """
1061 .toEqual YAML.parse YAML.dump ( 1064 .toEqual YAML.parse YAML.dump (
1062 'all my favorite symbols': '#:!/%.)', 1065 'all my favorite symbols': '#:!/%.)',
1063 'a few i hate': '&(*', 1066 'a few i hate': '&(*',
1064 'why do i hate them?': 'it\'s very hard to explain' 1067 'why do i hate them?': 'it\'s very hard to explain'
1065 ) 1068 )
1066   1069  
1067   1070  
1068 it 'can be double-quoted strings', -> 1071 it 'can be double-quoted strings', ->
1069   1072  
1070 expect YAML.parse """ 1073 expect YAML.parse """
1071 i know where i want my line breaks: "one here\\nand another here\\n" 1074 i know where i want my line breaks: "one here\\nand another here\\n"
1072 """ 1075 """
1073 .toEqual YAML.parse YAML.dump ( 1076 .toEqual YAML.parse YAML.dump (
1074 'i know where i want my line breaks': "one here\nand another here\n" 1077 'i know where i want my line breaks': "one here\nand another here\n"
1075 ) 1078 )
1076   1079  
1077   1080  
1078 it 'can be null', -> 1081 it 'can be null', ->
1079   1082  
1080 expect YAML.parse """ 1083 expect YAML.parse """
1081 name: Mr. Show 1084 name: Mr. Show
1082 hosted by: Bob and David 1085 hosted by: Bob and David
1083 date of next season: ~ 1086 date of next season: ~
1084 """ 1087 """
1085 .toEqual YAML.parse YAML.dump ( 1088 .toEqual YAML.parse YAML.dump (
1086 'name': 'Mr. Show' 1089 'name': 'Mr. Show'
1087 'hosted by': 'Bob and David' 1090 'hosted by': 'Bob and David'
1088 'date of next season': null 1091 'date of next season': null
1089 ) 1092 )
1090   1093  
1091   1094  
1092 it 'can be boolean', -> 1095 it 'can be boolean', ->
1093   1096  
1094 expect YAML.parse """ 1097 expect YAML.parse """
1095 Is Gus a Liar?: true 1098 Is Gus a Liar?: true
1096 Do I rely on Gus for Sustenance?: false 1099 Do I rely on Gus for Sustenance?: false
1097 """ 1100 """
1098 .toEqual YAML.parse YAML.dump ( 1101 .toEqual YAML.parse YAML.dump (
1099 'Is Gus a Liar?': true 1102 'Is Gus a Liar?': true
1100 'Do I rely on Gus for Sustenance?': false 1103 'Do I rely on Gus for Sustenance?': false
1101 ) 1104 )
1102   1105  
1103   1106  
1104 it 'can be integers', -> 1107 it 'can be integers', ->
1105   1108  
1106 expect YAML.parse """ 1109 expect YAML.parse """
1107 zero: 0 1110 zero: 0
1108 simple: 12 1111 simple: 12
1109 one-thousand: 1,000 1112 one-thousand: 1,000
1110 negative one-thousand: -1,000 1113 negative one-thousand: -1,000
1111 """ 1114 """
1112 .toEqual YAML.parse YAML.dump ( 1115 .toEqual YAML.parse YAML.dump (
1113 'zero': 0 1116 'zero': 0
1114 'simple': 12 1117 'simple': 12
1115 'one-thousand': 1000 1118 'one-thousand': 1000
1116 'negative one-thousand': -1000 1119 'negative one-thousand': -1000
1117 ) 1120 )
1118   1121  
1119   1122  
1120 it 'can be integers as map keys', -> 1123 it 'can be integers as map keys', ->
1121   1124  
1122 expect YAML.parse """ 1125 expect YAML.parse """
1123 1: one 1126 1: one
1124 2: two 1127 2: two
1125 3: three 1128 3: three
1126 """ 1129 """
1127 .toEqual YAML.parse YAML.dump ( 1130 .toEqual YAML.parse YAML.dump (
1128 1: 'one' 1131 1: 'one'
1129 2: 'two' 1132 2: 'two'
1130 3: 'three' 1133 3: 'three'
1131 ) 1134 )
1132   1135  
1133   1136  
1134 it 'can be floats', -> 1137 it 'can be floats', ->
1135   1138  
1136 expect YAML.parse """ 1139 expect YAML.parse """
1137 a simple float: 2.00 1140 a simple float: 2.00
1138 larger float: 1,000.09 1141 larger float: 1,000.09
1139 scientific notation: 1.00009e+3 1142 scientific notation: 1.00009e+3
1140 """ 1143 """
1141 .toEqual YAML.parse YAML.dump ( 1144 .toEqual YAML.parse YAML.dump (
1142 'a simple float': 2.0 1145 'a simple float': 2.0
1143 'larger float': 1000.09 1146 'larger float': 1000.09
1144 'scientific notation': 1000.09 1147 'scientific notation': 1000.09
1145 ) 1148 )
1146   1149  
1147   1150  
1148 it 'can be time', -> 1151 it 'can be time', ->
1149   1152  
1150 iso8601Date = new Date Date.UTC(2001, 12-1, 14, 21, 59, 43, 10) 1153 iso8601Date = new Date Date.UTC(2001, 12-1, 14, 21, 59, 43, 10)
1151 iso8601Date.setTime iso8601Date.getTime() - 5 * 3600 * 1000 1154 iso8601Date.setTime iso8601Date.getTime() + 5 * 3600 * 1000
1152   1155  
1153 spaceSeparatedDate = new Date Date.UTC(2001, 12-1, 14, 21, 59, 43, 10) 1156 spaceSeparatedDate = new Date Date.UTC(2001, 12-1, 14, 21, 59, 43, 10)
1154 spaceSeparatedDate.setTime spaceSeparatedDate.getTime() - 5 * 3600 * 1000 1157 spaceSeparatedDate.setTime spaceSeparatedDate.getTime() - 5 * 3600 * 1000
1155   1158  
1156 withDatesToTime = (input) -> 1159 withDatesToTime = (input) ->
1157 res = {} 1160 res = {}
1158 for key, val of input 1161 for key, val of input
1159 res[key] = Math.round(val.getTime() / 1000) * 1000 1162 res[key] = val.getTime()
1160 return res 1163 return res
1161   1164  
1162 expect withDatesToTime(YAML.parse """ 1165 expect withDatesToTime(YAML.parse """
1163 iso8601: 2001-12-14t21:59:43.10-05:00 1166 iso8601: 2001-12-14t21:59:43.010-05:00
1164 space seperated: 2001-12-14 21:59:43.10 -05:00 1167 space separated: 2001-12-14 21:59:43.010 +05:00
1165 """) 1168 """)
1166 .toEqual YAML.parse YAML.dump withDatesToTime ( 1169 .toEqual YAML.parse YAML.dump withDatesToTime (
1167 'iso8601': iso8601Date 1170 'iso8601': iso8601Date
1168 'space seperated': spaceSeparatedDate 1171 'space separated': spaceSeparatedDate
1169 ) 1172 )
1170   1173  
1171   1174  
1172 it 'can be date', -> 1175 it 'can be date', ->
1173   1176  
1174 aDate = new Date Date.UTC(1976, 7-1, 31, 0, 0, 0, 0) 1177 aDate = new Date Date.UTC(1976, 7-1, 31, 0, 0, 0, 0)
1175   1178  
1176 withDatesToTime = (input) -> 1179 withDatesToTime = (input) ->
1177 return input 1180 return input
1178 res = {} 1181 res = {}
1179 for key, val of input 1182 for key, val of input
1180 res[key] = Math.round(val.getTime() / 1000) * 1000 1183 res[key] = val.getTime()
1181 return res 1184 return res
1182   1185  
1183 expect withDatesToTime(YAML.parse """ 1186 expect withDatesToTime(YAML.parse """
1184 date: 1976-07-31 1187 date: 1976-07-31
1185 """) 1188 """)
1186 .toEqual YAML.parse YAML.dump withDatesToTime ( 1189 .toEqual YAML.parse YAML.dump withDatesToTime (
1187 'date': aDate 1190 'date': aDate
1188 ) 1191 )
1189   1192  
1190   1193  
1191   1194  
1192 describe 'Dumped YAML Blocks', -> 1195 describe 'Dumped YAML Blocks', ->
1193   1196  
1194 it 'can be single ending newline', -> 1197 it 'can be single ending newline', ->
1195   1198  
1196 expect YAML.parse """ 1199 expect YAML.parse """
1197 --- 1200 ---
1198 this: | 1201 this: |
1199 Foo 1202 Foo
1200 Bar 1203 Bar
1201 """ 1204 """
1202 .toEqual YAML.parse YAML.dump 'this': "Foo\nBar\n" 1205 .toEqual YAML.parse YAML.dump 'this': "Foo\nBar\n"
1203   1206  
1204   1207  
1205 it 'can be single ending newline with \'+\' indicator', -> 1208 it 'can be single ending newline with \'+\' indicator', ->
1206   1209  
1207 expect YAML.parse """ 1210 expect YAML.parse """
1208 normal: | 1211 normal: |
1209 extra new lines not kept 1212 extra new lines not kept
1210   1213  
1211 preserving: |+ 1214 preserving: |+
1212 extra new lines are kept 1215 extra new lines are kept
1213   1216  
1214   1217  
1215 dummy: value 1218 dummy: value
1216 """ 1219 """
1217 .toEqual YAML.parse YAML.dump ( 1220 .toEqual YAML.parse YAML.dump (
1218 'normal': "extra new lines not kept\n" 1221 'normal': "extra new lines not kept\n"
1219 'preserving': "extra new lines are kept\n\n\n" 1222 'preserving': "extra new lines are kept\n\n\n"
1220 'dummy': 'value' 1223 'dummy': 'value'
1221 ) 1224 )
1222   1225  
1223   1226  
1224 it 'can be multi-line block handling trailing newlines in function of \'+\', \'-\' indicators', -> 1227 it 'can be multi-line block handling trailing newlines in function of \'+\', \'-\' indicators', ->
1225   1228  
1226 expect YAML.parse """ 1229 expect YAML.parse """
1227 clipped: | 1230 clipped: |
1228 This has one newline. 1231 This has one newline.
1229   1232  
1230   1233  
1231   1234  
1232 same as "clipped" above: "This has one newline.\\n" 1235 same as "clipped" above: "This has one newline.\\n"
1233   1236  
1234 stripped: |- 1237 stripped: |-
1235 This has no newline. 1238 This has no newline.
1236   1239  
1237   1240  
1238   1241  
1239 same as "stripped" above: "This has no newline." 1242 same as "stripped" above: "This has no newline."
1240   1243  
1241 kept: |+ 1244 kept: |+
1242 This has four newlines. 1245 This has four newlines.
1243   1246  
1244   1247  
1245   1248  
1246 same as "kept" above: "This has four newlines.\\n\\n\\n\\n" 1249 same as "kept" above: "This has four newlines.\\n\\n\\n\\n"
1247 """ 1250 """
1248 .toEqual YAML.parse YAML.dump ( 1251 .toEqual YAML.parse YAML.dump (
1249 'clipped': "This has one newline.\n" 1252 'clipped': "This has one newline.\n"
1250 'same as "clipped" above': "This has one newline.\n" 1253 'same as "clipped" above': "This has one newline.\n"
1251 'stripped':'This has no newline.' 1254 'stripped':'This has no newline.'
1252 'same as "stripped" above': 'This has no newline.' 1255 'same as "stripped" above': 'This has no newline.'
1253 'kept': "This has four newlines.\n\n\n\n" 1256 'kept': "This has four newlines.\n\n\n\n"
1254 'same as "kept" above': "This has four newlines.\n\n\n\n" 1257 'same as "kept" above': "This has four newlines.\n\n\n\n"
1255 ) 1258 )
1256   1259  
1257   1260  
1258 it 'can be folded block in a sequence', -> 1261 it 'can be folded block in a sequence', ->
1259   1262  
1260 expect YAML.parse """ 1263 expect YAML.parse """
1261 --- 1264 ---
1262 - apple 1265 - apple
1263 - banana 1266 - banana
1264 - > 1267 - >
1265 can't you see 1268 can't you see
1266 the beauty of yaml? 1269 the beauty of yaml?
1267 hmm 1270 hmm
1268 - dog 1271 - dog
1269 """ 1272 """
1270 .toEqual YAML.parse YAML.dump [ 1273 .toEqual YAML.parse YAML.dump [
1271 'apple', 1274 'apple',
1272 'banana', 1275 'banana',
1273 "can't you see the beauty of yaml? hmm\n", 1276 "can't you see the beauty of yaml? hmm\n",
1274 'dog' 1277 'dog'
1275 ] 1278 ]
1276   1279  
1277   1280  
1278 it 'can be folded block as a mapping value', -> 1281 it 'can be folded block as a mapping value', ->
1279   1282  
1280 expect YAML.parse """ 1283 expect YAML.parse """
1281 --- 1284 ---
1282 quote: > 1285 quote: >
1283 Mark McGwire's 1286 Mark McGwire's
1284 year was crippled 1287 year was crippled
1285 by a knee injury. 1288 by a knee injury.
1286 source: espn 1289 source: espn
1287 """ 1290 """
1288 .toEqual YAML.parse YAML.dump ( 1291 .toEqual YAML.parse YAML.dump (
1289 'quote': "Mark McGwire's year was crippled by a knee injury.\n" 1292 'quote': "Mark McGwire's year was crippled by a knee injury.\n"
1290 'source': 'espn' 1293 'source': 'espn'
1291 ) 1294 )
1292   1295  
1293   1296  
1294 it 'can be folded block handling trailing newlines in function of \'+\', \'-\' indicators', -> 1297 it 'can be folded block handling trailing newlines in function of \'+\', \'-\' indicators', ->
1295   1298  
1296 expect YAML.parse """ 1299 expect YAML.parse """
1297 clipped: > 1300 clipped: >
1298 This has one newline. 1301 This has one newline.
1299   1302  
1300   1303  
1301   1304  
1302 same as "clipped" above: "This has one newline.\\n" 1305 same as "clipped" above: "This has one newline.\\n"
1303   1306  
1304 stripped: >- 1307 stripped: >-
1305 This has no newline. 1308 This has no newline.
1306   1309  
1307   1310  
1308   1311  
1309 same as "stripped" above: "This has no newline." 1312 same as "stripped" above: "This has no newline."
1310   1313  
1311 kept: >+ 1314 kept: >+
1312 This has four newlines. 1315 This has four newlines.
1313   1316  
1314   1317  
1315   1318  
1316 same as "kept" above: "This has four newlines.\\n\\n\\n\\n" 1319 same as "kept" above: "This has four newlines.\\n\\n\\n\\n"
1317 """ 1320 """
1318 .toEqual YAML.parse YAML.dump ( 1321 .toEqual YAML.parse YAML.dump (
1319 'clipped': "This has one newline.\n" 1322 'clipped': "This has one newline.\n"
1320 'same as "clipped" above': "This has one newline.\n" 1323 'same as "clipped" above': "This has one newline.\n"
1321 'stripped': 'This has no newline.' 1324 'stripped': 'This has no newline.'
1322 'same as "stripped" above': 'This has no newline.' 1325 'same as "stripped" above': 'This has no newline.'
1323 'kept': "This has four newlines.\n\n\n\n" 1326 'kept': "This has four newlines.\n\n\n\n"
1324 'same as "kept" above': "This has four newlines.\n\n\n\n" 1327 'same as "kept" above': "This has four newlines.\n\n\n\n"
1325 ) 1328 )
1326   1329  
1327   1330  
1328   1331  
1329 describe 'Dumped YAML Comments', -> 1332 describe 'Dumped YAML Comments', ->
1330   1333  
1331 it 'can begin the document', -> 1334 it 'can begin the document', ->
1332   1335  
1333 expect YAML.parse """ 1336 expect YAML.parse """
1334 # This is a comment 1337 # This is a comment
1335 hello: world 1338 hello: world
1336 """ 1339 """
1337 .toEqual YAML.parse YAML.dump ( 1340 .toEqual YAML.parse YAML.dump (
1338 hello: 'world' 1341 hello: 'world'
1339 ) 1342 )
1340   1343  
1341   1344  
1342 it 'can finish a line', -> 1345 it 'can finish a line', ->
1343   1346  
1344 expect YAML.parse """ 1347 expect YAML.parse """
1345 hello: world # This is a comment 1348 hello: world # This is a comment
1346 """ 1349 """
1347 .toEqual YAML.parse YAML.dump ( 1350 .toEqual YAML.parse YAML.dump (
1348 hello: 'world' 1351 hello: 'world'
1349 ) 1352 )
1350   1353  
1351   1354  
1352 it 'can end the document', -> 1355 it 'can end the document', ->
1353   1356  
1354 expect YAML.parse """ 1357 expect YAML.parse """
1355 hello: world 1358 hello: world
1356 # This is a comment 1359 # This is a comment
1357 """ 1360 """
1358 .toEqual YAML.parse YAML.dump ( 1361 .toEqual YAML.parse YAML.dump (
1359 hello: 'world' 1362 hello: 'world'
1360 ) 1363 )
1361   1364  
1362   1365  
1363   1366  
1364 describe 'Dumped YAML Aliases and Anchors', -> 1367 describe 'Dumped YAML Aliases and Anchors', ->
1365   1368  
1366 it 'can be simple alias', -> 1369 it 'can be simple alias', ->
1367   1370  
1368 expect YAML.parse """ 1371 expect YAML.parse """
1369 - &showell Steve 1372 - &showell Steve
1370 - Clark 1373 - Clark
1371 - Brian 1374 - Brian
1372 - Oren 1375 - Oren
1373 - *showell 1376 - *showell
1374 """ 1377 """
1375 .toEqual YAML.parse YAML.dump ['Steve', 'Clark', 'Brian', 'Oren', 'Steve'] 1378 .toEqual YAML.parse YAML.dump ['Steve', 'Clark', 'Brian', 'Oren', 'Steve']
1376   1379  
1377   1380  
1378 it 'can be alias of a mapping', -> 1381 it 'can be alias of a mapping', ->
1379   1382  
1380 expect YAML.parse """ 1383 expect YAML.parse """
1381 - &hello 1384 - &hello
1382 Meat: pork 1385 Meat: pork
1383 Starch: potato 1386 Starch: potato
1384 - banana 1387 - banana
1385 - *hello 1388 - *hello
1386 """ 1389 """
1387 .toEqual YAML.parse YAML.dump [ 1390 .toEqual YAML.parse YAML.dump [
1388 Meat: 'pork', Starch: 'potato' 1391 Meat: 'pork', Starch: 'potato'
1389 , 1392 ,
1390 'banana' 1393 'banana'
1391 , 1394 ,
1392 Meat: 'pork', Starch: 'potato' 1395 Meat: 'pork', Starch: 'potato'
1393 ] 1396 ]
1394   1397  
1395   1398  
1396   1399  
1397 describe 'Dumped YAML Documents', -> 1400 describe 'Dumped YAML Documents', ->
1398   1401  
1399 it 'can have YAML header', -> 1402 it 'can have YAML header', ->
1400   1403  
1401 expect YAML.parse """ 1404 expect YAML.parse """
1402 --- %YAML:1.0 1405 --- %YAML:1.0
1403 foo: 1 1406 foo: 1
1404 bar: 2 1407 bar: 2
1405 """ 1408 """
1406 .toEqual YAML.parse YAML.dump ( 1409 .toEqual YAML.parse YAML.dump (
1407 foo: 1 1410 foo: 1
1408 bar: 2 1411 bar: 2
1409 ) 1412 )
1410   1413  
1411   1414  
1412 it 'can have leading document separator', -> 1415 it 'can have leading document separator', ->
1413   1416  
1414 expect YAML.parse """ 1417 expect YAML.parse """
1415 --- 1418 ---
1416 - foo: 1 1419 - foo: 1
1417 bar: 2 1420 bar: 2
1418 """ 1421 """
1419 .toEqual YAML.parse YAML.dump [( 1422 .toEqual YAML.parse YAML.dump [(
1420 foo: 1 1423 foo: 1
1421 bar: 2 1424 bar: 2
1422 )] 1425 )]
1423   1426  
1424   1427  
1425 it 'can have multiple document separators in block', -> 1428 it 'can have multiple document separators in block', ->
1426   1429  
1427 expect YAML.parse """ 1430 expect YAML.parse """
1428 foo: | 1431 foo: |
1429 --- 1432 ---
1430 foo: bar 1433 foo: bar
1431 --- 1434 ---
1432 yo: baz 1435 yo: baz
1433 bar: | 1436 bar: |
1434 fooness 1437 fooness
1435 """ 1438 """
1436 .toEqual YAML.parse YAML.dump ( 1439 .toEqual YAML.parse YAML.dump (
1437 foo: "---\nfoo: bar\n---\nyo: baz\n" 1440 foo: "---\nfoo: bar\n---\nyo: baz\n"
1438 bar: "fooness\n" 1441 bar: "fooness\n"
1439 ) 1442 )
1440   1443  
1441   1444  
1442 # Loading 1445 # Loading
1443 # (disable test when running locally from file) 1446 # (disable test when running locally from file)
1444 # 1447 #
1445 url = document?.location?.href 1448 url = document?.location?.href
1446 if not(url?) or url.indexOf('file://') is -1 1449 if not(url?) or url.indexOf('file://') is -1
1447   1450  
1448 examplePath = 'spec/example.yml' 1451 examplePath = 'spec/example.yml'
1449 if __dirname? 1452 if __dirname?
1450 examplePath = __dirname+'/example.yml' 1453 examplePath = __dirname+'/example.yml'
1451   1454  
1452 describe 'YAML loading', -> 1455 describe 'YAML loading', ->
1453   1456  
1454 it 'can be done synchronously', -> 1457 it 'can be done synchronously', ->
1455   1458  
1456 expect(YAML.load(examplePath)).toEqual ( 1459 expect(YAML.load(examplePath)).toEqual (
1457 this: 'is' 1460 this: 'is'
1458 a: ['YAML', 'example'] 1461 a: ['YAML', 'example']
1459 ) 1462 )
1460   1463  
1461   1464  
1462 it 'can be done asynchronously', (done) -> 1465 it 'can be done asynchronously', (done) ->
1463   1466  
1464 YAML.load examplePath, (result) -> 1467 YAML.load examplePath, (result) ->
1465   1468  
1466 expect(result).toEqual ( 1469 expect(result).toEqual (
1467 this: 'is' 1470 this: 'is'
1468 a: ['YAML', 'example'] 1471 a: ['YAML', 'example']
1469 ) 1472 )
1470   1473  
1471 done() 1474 done()
1472   1475