money_parser 0.0.2 → 0.0.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.
data/specification.rb CHANGED
@@ -1,5 +1,9 @@
1
1
  SPECIFICATION = [
2
2
  [nil , nil],
3
+ [',' , nil],
4
+ [',,' , nil],
5
+ ['.' , nil],
6
+ ['..' , nil],
3
7
  ["2000.01" , 2000.01],
4
8
  ["2000,01" , 2000.01],
5
9
  ["2000.1" , 2000.1],
@@ -7,12 +7,92 @@ describe('moneyParse', function(){
7
7
  assert.equal(null, parseMoney(null));
8
8
  });
9
9
 
10
+ it('"," should be parsed as null ', function(){
11
+ assert.equal(null, parseMoney(","));
12
+ });
13
+
14
+ it('"$," should be parsed as null (with a dollar sign)', function(){
15
+ assert.equal(null, parseMoney("$,"));
16
+ });
17
+
18
+ it('"€," should be parsed as null (with a euro sign)', function(){
19
+ assert.equal(null, parseMoney("€,"));
20
+ });
21
+
22
+ it('"£," should be parsed as null (with a pound sign)', function(){
23
+ assert.equal(null, parseMoney("£,"));
24
+ });
25
+
26
+ it('"₤," should be parsed as null (with a pound sign)', function(){
27
+ assert.equal(null, parseMoney("₤,"));
28
+ });
29
+
30
+ it('",," should be parsed as null ', function(){
31
+ assert.equal(null, parseMoney(",,"));
32
+ });
33
+
34
+ it('"$,," should be parsed as null (with a dollar sign)', function(){
35
+ assert.equal(null, parseMoney("$,,"));
36
+ });
37
+
38
+ it('"€,," should be parsed as null (with a euro sign)', function(){
39
+ assert.equal(null, parseMoney("€,,"));
40
+ });
41
+
42
+ it('"£,," should be parsed as null (with a pound sign)', function(){
43
+ assert.equal(null, parseMoney("£,,"));
44
+ });
45
+
46
+ it('"₤,," should be parsed as null (with a pound sign)', function(){
47
+ assert.equal(null, parseMoney("₤,,"));
48
+ });
49
+
50
+ it('"." should be parsed as null ', function(){
51
+ assert.equal(null, parseMoney("."));
52
+ });
53
+
54
+ it('"$." should be parsed as null (with a dollar sign)', function(){
55
+ assert.equal(null, parseMoney("$."));
56
+ });
57
+
58
+ it('"€." should be parsed as null (with a euro sign)', function(){
59
+ assert.equal(null, parseMoney("€."));
60
+ });
61
+
62
+ it('"£." should be parsed as null (with a pound sign)', function(){
63
+ assert.equal(null, parseMoney("£."));
64
+ });
65
+
66
+ it('"₤." should be parsed as null (with a pound sign)', function(){
67
+ assert.equal(null, parseMoney("₤."));
68
+ });
69
+
70
+ it('".." should be parsed as null ', function(){
71
+ assert.equal(null, parseMoney(".."));
72
+ });
73
+
74
+ it('"$.." should be parsed as null (with a dollar sign)', function(){
75
+ assert.equal(null, parseMoney("$.."));
76
+ });
77
+
78
+ it('"€.." should be parsed as null (with a euro sign)', function(){
79
+ assert.equal(null, parseMoney("€.."));
80
+ });
81
+
82
+ it('"£.." should be parsed as null (with a pound sign)', function(){
83
+ assert.equal(null, parseMoney("£.."));
84
+ });
85
+
86
+ it('"₤.." should be parsed as null (with a pound sign)', function(){
87
+ assert.equal(null, parseMoney("₤.."));
88
+ });
89
+
10
90
  it('"2000.01" should be parsed as 2000.01 ', function(){
11
91
  assert.equal(2000.01, parseMoney("2000.01"));
12
92
  });
13
93
 
14
- it('" - 2000.01" should be parsed as -2000.01 (negative amount)', function(){
15
- assert.equal(-2000.01, parseMoney(" - 2000.01"));
94
+ it('"-2000.01" should be parsed as -2000.01 (negative amount)', function(){
95
+ assert.equal(-2000.01, parseMoney("-2000.01"));
16
96
  });
17
97
 
18
98
  it('"20o0.01" should be parsed as 2000.01 (with O instead of 0)', function(){
@@ -39,12 +119,12 @@ describe('moneyParse', function(){
39
119
  assert.equal(2000.01, parseMoney("2000,01"));
40
120
  });
41
121
 
42
- it('"- 2000,01" should be parsed as -2000.01 (negative amount)', function(){
43
- assert.equal(-2000.01, parseMoney("- 2000,01"));
122
+ it('"-2000,01" should be parsed as -2000.01 (negative amount)', function(){
123
+ assert.equal(-2000.01, parseMoney("-2000,01"));
44
124
  });
45
125
 
46
- it('"2o00,01" should be parsed as 2000.01 (with O instead of 0)', function(){
47
- assert.equal(2000.01, parseMoney("2o00,01"));
126
+ it('"2000,o1" should be parsed as 2000.01 (with O instead of 0)', function(){
127
+ assert.equal(2000.01, parseMoney("2000,o1"));
48
128
  });
49
129
 
50
130
  it('"$2000,01" should be parsed as 2000.01 (with a dollar sign)', function(){
@@ -67,8 +147,8 @@ describe('moneyParse', function(){
67
147
  assert.equal(2000.1, parseMoney("2000.1"));
68
148
  });
69
149
 
70
- it('" - 2000.1" should be parsed as -2000.1 (negative amount)', function(){
71
- assert.equal(-2000.1, parseMoney(" - 2000.1"));
150
+ it('"-2000.1" should be parsed as -2000.1 (negative amount)', function(){
151
+ assert.equal(-2000.1, parseMoney("-2000.1"));
72
152
  });
73
153
 
74
154
  it('"20o0.1" should be parsed as 2000.1 (with O instead of 0)', function(){
@@ -99,8 +179,8 @@ describe('moneyParse', function(){
99
179
  assert.equal(-2000.1, parseMoney(" -2000,1"));
100
180
  });
101
181
 
102
- it('"20o0,1" should be parsed as 2000.1 (with O instead of 0)', function(){
103
- assert.equal(2000.1, parseMoney("20o0,1"));
182
+ it('"2o00,1" should be parsed as 2000.1 (with O instead of 0)', function(){
183
+ assert.equal(2000.1, parseMoney("2o00,1"));
104
184
  });
105
185
 
106
186
  it('"$2000,1" should be parsed as 2000.1 (with a dollar sign)', function(){
@@ -127,8 +207,8 @@ describe('moneyParse', function(){
127
207
  assert.equal(-2000.0, parseMoney(" - 2000"));
128
208
  });
129
209
 
130
- it('"20o0" should be parsed as 2000.0 (with O instead of 0)', function(){
131
- assert.equal(2000.0, parseMoney("20o0"));
210
+ it('"2o00" should be parsed as 2000.0 (with O instead of 0)', function(){
211
+ assert.equal(2000.0, parseMoney("2o00"));
132
212
  });
133
213
 
134
214
  it('"$2000" should be parsed as 2000.0 (with a dollar sign)', function(){
@@ -151,8 +231,8 @@ describe('moneyParse', function(){
151
231
  assert.equal(0.01, parseMoney(".01"));
152
232
  });
153
233
 
154
- it('" - .01" should be parsed as -0.01 (negative amount)', function(){
155
- assert.equal(-0.01, parseMoney(" - .01"));
234
+ it('"-.01" should be parsed as -0.01 (negative amount)', function(){
235
+ assert.equal(-0.01, parseMoney("-.01"));
156
236
  });
157
237
 
158
238
  it('".o1" should be parsed as 0.01 (with O instead of 0)', function(){
@@ -179,8 +259,8 @@ describe('moneyParse', function(){
179
259
  assert.equal(0.01, parseMoney(",01"));
180
260
  });
181
261
 
182
- it('"- ,01" should be parsed as -0.01 (negative amount)', function(){
183
- assert.equal(-0.01, parseMoney("- ,01"));
262
+ it('" -,01" should be parsed as -0.01 (negative amount)', function(){
263
+ assert.equal(-0.01, parseMoney(" -,01"));
184
264
  });
185
265
 
186
266
  it('",o1" should be parsed as 0.01 (with O instead of 0)', function(){
@@ -207,8 +287,8 @@ describe('moneyParse', function(){
207
287
  assert.equal(0.01, parseMoney("0.01"));
208
288
  });
209
289
 
210
- it('" - 0.01" should be parsed as -0.01 (negative amount)', function(){
211
- assert.equal(-0.01, parseMoney(" - 0.01"));
290
+ it('" -0.01" should be parsed as -0.01 (negative amount)', function(){
291
+ assert.equal(-0.01, parseMoney(" -0.01"));
212
292
  });
213
293
 
214
294
  it('"o.01" should be parsed as 0.01 (with O instead of 0)', function(){
@@ -235,12 +315,12 @@ describe('moneyParse', function(){
235
315
  assert.equal(0.01, parseMoney("0,01"));
236
316
  });
237
317
 
238
- it('" -0,01" should be parsed as -0.01 (negative amount)', function(){
239
- assert.equal(-0.01, parseMoney(" -0,01"));
318
+ it('" - 0,01" should be parsed as -0.01 (negative amount)', function(){
319
+ assert.equal(-0.01, parseMoney(" - 0,01"));
240
320
  });
241
321
 
242
- it('"0,o1" should be parsed as 0.01 (with O instead of 0)', function(){
243
- assert.equal(0.01, parseMoney("0,o1"));
322
+ it('"o,01" should be parsed as 0.01 (with O instead of 0)', function(){
323
+ assert.equal(0.01, parseMoney("o,01"));
244
324
  });
245
325
 
246
326
  it('"$0,01" should be parsed as 0.01 (with a dollar sign)', function(){
@@ -339,8 +419,8 @@ describe('moneyParse', function(){
339
419
  assert.equal(0.1, parseMoney("0,1"));
340
420
  });
341
421
 
342
- it('"-0,1" should be parsed as -0.1 (negative amount)', function(){
343
- assert.equal(-0.1, parseMoney("-0,1"));
422
+ it('"- 0,1" should be parsed as -0.1 (negative amount)', function(){
423
+ assert.equal(-0.1, parseMoney("- 0,1"));
344
424
  });
345
425
 
346
426
  it('"o,1" should be parsed as 0.1 (with O instead of 0)', function(){
@@ -367,12 +447,12 @@ describe('moneyParse', function(){
367
447
  assert.equal(2000.01, parseMoney("2,000.01"));
368
448
  });
369
449
 
370
- it('" - 2,000.01" should be parsed as -2000.01 (negative amount)', function(){
371
- assert.equal(-2000.01, parseMoney(" - 2,000.01"));
450
+ it('"-2,000.01" should be parsed as -2000.01 (negative amount)', function(){
451
+ assert.equal(-2000.01, parseMoney("-2,000.01"));
372
452
  });
373
453
 
374
- it('"2,000.o1" should be parsed as 2000.01 (with O instead of 0)', function(){
375
- assert.equal(2000.01, parseMoney("2,000.o1"));
454
+ it('"2,0o0.01" should be parsed as 2000.01 (with O instead of 0)', function(){
455
+ assert.equal(2000.01, parseMoney("2,0o0.01"));
376
456
  });
377
457
 
378
458
  it('"$2,000.01" should be parsed as 2000.01 (with a dollar sign)', function(){
@@ -395,12 +475,12 @@ describe('moneyParse', function(){
395
475
  assert.equal(2000.01, parseMoney("2.000,01"));
396
476
  });
397
477
 
398
- it('" -2.000,01" should be parsed as -2000.01 (negative amount)', function(){
399
- assert.equal(-2000.01, parseMoney(" -2.000,01"));
478
+ it('"-2.000,01" should be parsed as -2000.01 (negative amount)', function(){
479
+ assert.equal(-2000.01, parseMoney("-2.000,01"));
400
480
  });
401
481
 
402
- it('"2.000,o1" should be parsed as 2000.01 (with O instead of 0)', function(){
403
- assert.equal(2000.01, parseMoney("2.000,o1"));
482
+ it('"2.o00,01" should be parsed as 2000.01 (with O instead of 0)', function(){
483
+ assert.equal(2000.01, parseMoney("2.o00,01"));
404
484
  });
405
485
 
406
486
  it('"$2.000,01" should be parsed as 2000.01 (with a dollar sign)', function(){
@@ -423,12 +503,12 @@ describe('moneyParse', function(){
423
503
  assert.equal(2000.01, parseMoney("2 000.01"));
424
504
  });
425
505
 
426
- it('"-2 000.01" should be parsed as -2000.01 (negative amount)', function(){
427
- assert.equal(-2000.01, parseMoney("-2 000.01"));
506
+ it('"- 2 000.01" should be parsed as -2000.01 (negative amount)', function(){
507
+ assert.equal(-2000.01, parseMoney("- 2 000.01"));
428
508
  });
429
509
 
430
- it('"2 00o.01" should be parsed as 2000.01 (with O instead of 0)', function(){
431
- assert.equal(2000.01, parseMoney("2 00o.01"));
510
+ it('"2 000.o1" should be parsed as 2000.01 (with O instead of 0)', function(){
511
+ assert.equal(2000.01, parseMoney("2 000.o1"));
432
512
  });
433
513
 
434
514
  it('"$2 000.01" should be parsed as 2000.01 (with a dollar sign)', function(){
@@ -455,8 +535,8 @@ describe('moneyParse', function(){
455
535
  assert.equal(-2000.01, parseMoney("- 2 000,01"));
456
536
  });
457
537
 
458
- it('"2 o00,01" should be parsed as 2000.01 (with O instead of 0)', function(){
459
- assert.equal(2000.01, parseMoney("2 o00,01"));
538
+ it('"2 000,o1" should be parsed as 2000.01 (with O instead of 0)', function(){
539
+ assert.equal(2000.01, parseMoney("2 000,o1"));
460
540
  });
461
541
 
462
542
  it('"$2 000,01" should be parsed as 2000.01 (with a dollar sign)', function(){
@@ -479,8 +559,8 @@ describe('moneyParse', function(){
479
559
  assert.equal(1222000.01, parseMoney("1,222,000.01"));
480
560
  });
481
561
 
482
- it('" - 1,222,000.01" should be parsed as -1222000.01 (negative amount)', function(){
483
- assert.equal(-1222000.01, parseMoney(" - 1,222,000.01"));
562
+ it('"-1,222,000.01" should be parsed as -1222000.01 (negative amount)', function(){
563
+ assert.equal(-1222000.01, parseMoney("-1,222,000.01"));
484
564
  });
485
565
 
486
566
  it('"1,222,o00.01" should be parsed as 1222000.01 (with O instead of 0)', function(){
@@ -511,8 +591,8 @@ describe('moneyParse', function(){
511
591
  assert.equal(-1222000.01, parseMoney("-1.222.000,01"));
512
592
  });
513
593
 
514
- it('"1.222.o00,01" should be parsed as 1222000.01 (with O instead of 0)', function(){
515
- assert.equal(1222000.01, parseMoney("1.222.o00,01"));
594
+ it('"1.222.0o0,01" should be parsed as 1222000.01 (with O instead of 0)', function(){
595
+ assert.equal(1222000.01, parseMoney("1.222.0o0,01"));
516
596
  });
517
597
 
518
598
  it('"$1.222.000,01" should be parsed as 1222000.01 (with a dollar sign)', function(){
@@ -535,12 +615,12 @@ describe('moneyParse', function(){
535
615
  assert.equal(1222000.01, parseMoney("1 222 000.01"));
536
616
  });
537
617
 
538
- it('" - 1 222 000.01" should be parsed as -1222000.01 (negative amount)', function(){
539
- assert.equal(-1222000.01, parseMoney(" - 1 222 000.01"));
618
+ it('" -1 222 000.01" should be parsed as -1222000.01 (negative amount)', function(){
619
+ assert.equal(-1222000.01, parseMoney(" -1 222 000.01"));
540
620
  });
541
621
 
542
- it('"1 222 000.o1" should be parsed as 1222000.01 (with O instead of 0)', function(){
543
- assert.equal(1222000.01, parseMoney("1 222 000.o1"));
622
+ it('"1 222 0o0.01" should be parsed as 1222000.01 (with O instead of 0)', function(){
623
+ assert.equal(1222000.01, parseMoney("1 222 0o0.01"));
544
624
  });
545
625
 
546
626
  it('"$1 222 000.01" should be parsed as 1222000.01 (with a dollar sign)', function(){
@@ -567,8 +647,8 @@ describe('moneyParse', function(){
567
647
  assert.equal(-1222000.01, parseMoney(" - 1 222 000,01"));
568
648
  });
569
649
 
570
- it('"1 222 000,o1" should be parsed as 1222000.01 (with O instead of 0)', function(){
571
- assert.equal(1222000.01, parseMoney("1 222 000,o1"));
650
+ it('"1 222 0o0,01" should be parsed as 1222000.01 (with O instead of 0)', function(){
651
+ assert.equal(1222000.01, parseMoney("1 222 0o0,01"));
572
652
  });
573
653
 
574
654
  it('"$1 222 000,01" should be parsed as 1222000.01 (with a dollar sign)', function(){
@@ -591,8 +671,8 @@ describe('moneyParse', function(){
591
671
  assert.equal(2000.1, parseMoney("2,000.1"));
592
672
  });
593
673
 
594
- it('"-2,000.1" should be parsed as -2000.1 (negative amount)', function(){
595
- assert.equal(-2000.1, parseMoney("-2,000.1"));
674
+ it('"- 2,000.1" should be parsed as -2000.1 (negative amount)', function(){
675
+ assert.equal(-2000.1, parseMoney("- 2,000.1"));
596
676
  });
597
677
 
598
678
  it('"2,0o0.1" should be parsed as 2000.1 (with O instead of 0)', function(){
@@ -619,12 +699,12 @@ describe('moneyParse', function(){
619
699
  assert.equal(2000.1, parseMoney("2.000,1"));
620
700
  });
621
701
 
622
- it('"-2.000,1" should be parsed as -2000.1 (negative amount)', function(){
623
- assert.equal(-2000.1, parseMoney("-2.000,1"));
702
+ it('" -2.000,1" should be parsed as -2000.1 (negative amount)', function(){
703
+ assert.equal(-2000.1, parseMoney(" -2.000,1"));
624
704
  });
625
705
 
626
- it('"2.o00,1" should be parsed as 2000.1 (with O instead of 0)', function(){
627
- assert.equal(2000.1, parseMoney("2.o00,1"));
706
+ it('"2.00o,1" should be parsed as 2000.1 (with O instead of 0)', function(){
707
+ assert.equal(2000.1, parseMoney("2.00o,1"));
628
708
  });
629
709
 
630
710
  it('"$2.000,1" should be parsed as 2000.1 (with a dollar sign)', function(){
@@ -647,12 +727,12 @@ describe('moneyParse', function(){
647
727
  assert.equal(2000.1, parseMoney("2 000.1"));
648
728
  });
649
729
 
650
- it('"- 2 000.1" should be parsed as -2000.1 (negative amount)', function(){
651
- assert.equal(-2000.1, parseMoney("- 2 000.1"));
730
+ it('" -2 000.1" should be parsed as -2000.1 (negative amount)', function(){
731
+ assert.equal(-2000.1, parseMoney(" -2 000.1"));
652
732
  });
653
733
 
654
- it('"2 o00.1" should be parsed as 2000.1 (with O instead of 0)', function(){
655
- assert.equal(2000.1, parseMoney("2 o00.1"));
734
+ it('"2 0o0.1" should be parsed as 2000.1 (with O instead of 0)', function(){
735
+ assert.equal(2000.1, parseMoney("2 0o0.1"));
656
736
  });
657
737
 
658
738
  it('"$2 000.1" should be parsed as 2000.1 (with a dollar sign)', function(){
@@ -675,12 +755,12 @@ describe('moneyParse', function(){
675
755
  assert.equal(2000.1, parseMoney("2 000,1"));
676
756
  });
677
757
 
678
- it('" - 2 000,1" should be parsed as -2000.1 (negative amount)', function(){
679
- assert.equal(-2000.1, parseMoney(" - 2 000,1"));
758
+ it('"-2 000,1" should be parsed as -2000.1 (negative amount)', function(){
759
+ assert.equal(-2000.1, parseMoney("-2 000,1"));
680
760
  });
681
761
 
682
- it('"2 0o0,1" should be parsed as 2000.1 (with O instead of 0)', function(){
683
- assert.equal(2000.1, parseMoney("2 0o0,1"));
762
+ it('"2 o00,1" should be parsed as 2000.1 (with O instead of 0)', function(){
763
+ assert.equal(2000.1, parseMoney("2 o00,1"));
684
764
  });
685
765
 
686
766
  it('"$2 000,1" should be parsed as 2000.1 (with a dollar sign)', function(){
@@ -703,12 +783,12 @@ describe('moneyParse', function(){
703
783
  assert.equal(1222000.1, parseMoney("1,222,000.1"));
704
784
  });
705
785
 
706
- it('"- 1,222,000.1" should be parsed as -1222000.1 (negative amount)', function(){
707
- assert.equal(-1222000.1, parseMoney("- 1,222,000.1"));
786
+ it('"-1,222,000.1" should be parsed as -1222000.1 (negative amount)', function(){
787
+ assert.equal(-1222000.1, parseMoney("-1,222,000.1"));
708
788
  });
709
789
 
710
- it('"1,222,00o.1" should be parsed as 1222000.1 (with O instead of 0)', function(){
711
- assert.equal(1222000.1, parseMoney("1,222,00o.1"));
790
+ it('"1,222,0o0.1" should be parsed as 1222000.1 (with O instead of 0)', function(){
791
+ assert.equal(1222000.1, parseMoney("1,222,0o0.1"));
712
792
  });
713
793
 
714
794
  it('"$1,222,000.1" should be parsed as 1222000.1 (with a dollar sign)', function(){
@@ -735,8 +815,8 @@ describe('moneyParse', function(){
735
815
  assert.equal(-1222000.1, parseMoney("- 1.222.000,1"));
736
816
  });
737
817
 
738
- it('"1.222.0o0,1" should be parsed as 1222000.1 (with O instead of 0)', function(){
739
- assert.equal(1222000.1, parseMoney("1.222.0o0,1"));
818
+ it('"1.222.00o,1" should be parsed as 1222000.1 (with O instead of 0)', function(){
819
+ assert.equal(1222000.1, parseMoney("1.222.00o,1"));
740
820
  });
741
821
 
742
822
  it('"$1.222.000,1" should be parsed as 1222000.1 (with a dollar sign)', function(){
@@ -763,8 +843,8 @@ describe('moneyParse', function(){
763
843
  assert.equal(-1222000.1, parseMoney(" - 1 222 000.1"));
764
844
  });
765
845
 
766
- it('"1 222 00o.1" should be parsed as 1222000.1 (with O instead of 0)', function(){
767
- assert.equal(1222000.1, parseMoney("1 222 00o.1"));
846
+ it('"1 222 0o0.1" should be parsed as 1222000.1 (with O instead of 0)', function(){
847
+ assert.equal(1222000.1, parseMoney("1 222 0o0.1"));
768
848
  });
769
849
 
770
850
  it('"$1 222 000.1" should be parsed as 1222000.1 (with a dollar sign)', function(){
@@ -787,8 +867,8 @@ describe('moneyParse', function(){
787
867
  assert.equal(1222000.1, parseMoney("1 222 000,1"));
788
868
  });
789
869
 
790
- it('" - 1 222 000,1" should be parsed as -1222000.1 (negative amount)', function(){
791
- assert.equal(-1222000.1, parseMoney(" - 1 222 000,1"));
870
+ it('" -1 222 000,1" should be parsed as -1222000.1 (negative amount)', function(){
871
+ assert.equal(-1222000.1, parseMoney(" -1 222 000,1"));
792
872
  });
793
873
 
794
874
  it('"1 222 00o,1" should be parsed as 1222000.1 (with O instead of 0)', function(){
@@ -815,12 +895,12 @@ describe('moneyParse', function(){
815
895
  assert.equal(2000.1, parseMoney("2,000.10"));
816
896
  });
817
897
 
818
- it('"- 2,000.10" should be parsed as -2000.1 (negative amount)', function(){
819
- assert.equal(-2000.1, parseMoney("- 2,000.10"));
898
+ it('" -2,000.10" should be parsed as -2000.1 (negative amount)', function(){
899
+ assert.equal(-2000.1, parseMoney(" -2,000.10"));
820
900
  });
821
901
 
822
- it('"2,000.1o" should be parsed as 2000.1 (with O instead of 0)', function(){
823
- assert.equal(2000.1, parseMoney("2,000.1o"));
902
+ it('"2,0o0.10" should be parsed as 2000.1 (with O instead of 0)', function(){
903
+ assert.equal(2000.1, parseMoney("2,0o0.10"));
824
904
  });
825
905
 
826
906
  it('"$2,000.10" should be parsed as 2000.1 (with a dollar sign)', function(){
@@ -843,8 +923,8 @@ describe('moneyParse', function(){
843
923
  assert.equal(2000.1, parseMoney("2.000,10"));
844
924
  });
845
925
 
846
- it('"- 2.000,10" should be parsed as -2000.1 (negative amount)', function(){
847
- assert.equal(-2000.1, parseMoney("- 2.000,10"));
926
+ it('" - 2.000,10" should be parsed as -2000.1 (negative amount)', function(){
927
+ assert.equal(-2000.1, parseMoney(" - 2.000,10"));
848
928
  });
849
929
 
850
930
  it('"2.00o,10" should be parsed as 2000.1 (with O instead of 0)', function(){
@@ -871,8 +951,8 @@ describe('moneyParse', function(){
871
951
  assert.equal(2000.1, parseMoney("2 000.10"));
872
952
  });
873
953
 
874
- it('"- 2 000.10" should be parsed as -2000.1 (negative amount)', function(){
875
- assert.equal(-2000.1, parseMoney("- 2 000.10"));
954
+ it('" -2 000.10" should be parsed as -2000.1 (negative amount)', function(){
955
+ assert.equal(-2000.1, parseMoney(" -2 000.10"));
876
956
  });
877
957
 
878
958
  it('"2 o00.10" should be parsed as 2000.1 (with O instead of 0)', function(){
@@ -903,8 +983,8 @@ describe('moneyParse', function(){
903
983
  assert.equal(-2000.1, parseMoney(" - 2 000,10"));
904
984
  });
905
985
 
906
- it('"2 000,1o" should be parsed as 2000.1 (with O instead of 0)', function(){
907
- assert.equal(2000.1, parseMoney("2 000,1o"));
986
+ it('"2 00o,10" should be parsed as 2000.1 (with O instead of 0)', function(){
987
+ assert.equal(2000.1, parseMoney("2 00o,10"));
908
988
  });
909
989
 
910
990
  it('"$2 000,10" should be parsed as 2000.1 (with a dollar sign)', function(){
@@ -927,12 +1007,12 @@ describe('moneyParse', function(){
927
1007
  assert.equal(1222000.1, parseMoney("1,222,000.10"));
928
1008
  });
929
1009
 
930
- it('" - 1,222,000.10" should be parsed as -1222000.1 (negative amount)', function(){
931
- assert.equal(-1222000.1, parseMoney(" - 1,222,000.10"));
1010
+ it('" -1,222,000.10" should be parsed as -1222000.1 (negative amount)', function(){
1011
+ assert.equal(-1222000.1, parseMoney(" -1,222,000.10"));
932
1012
  });
933
1013
 
934
- it('"1,222,000.1o" should be parsed as 1222000.1 (with O instead of 0)', function(){
935
- assert.equal(1222000.1, parseMoney("1,222,000.1o"));
1014
+ it('"1,222,00o.10" should be parsed as 1222000.1 (with O instead of 0)', function(){
1015
+ assert.equal(1222000.1, parseMoney("1,222,00o.10"));
936
1016
  });
937
1017
 
938
1018
  it('"$1,222,000.10" should be parsed as 1222000.1 (with a dollar sign)', function(){
@@ -955,12 +1035,12 @@ describe('moneyParse', function(){
955
1035
  assert.equal(1222000.1, parseMoney("1.222.000,10"));
956
1036
  });
957
1037
 
958
- it('"-1.222.000,10" should be parsed as -1222000.1 (negative amount)', function(){
959
- assert.equal(-1222000.1, parseMoney("-1.222.000,10"));
1038
+ it('" - 1.222.000,10" should be parsed as -1222000.1 (negative amount)', function(){
1039
+ assert.equal(-1222000.1, parseMoney(" - 1.222.000,10"));
960
1040
  });
961
1041
 
962
- it('"1.222.00o,10" should be parsed as 1222000.1 (with O instead of 0)', function(){
963
- assert.equal(1222000.1, parseMoney("1.222.00o,10"));
1042
+ it('"1.222.o00,10" should be parsed as 1222000.1 (with O instead of 0)', function(){
1043
+ assert.equal(1222000.1, parseMoney("1.222.o00,10"));
964
1044
  });
965
1045
 
966
1046
  it('"$1.222.000,10" should be parsed as 1222000.1 (with a dollar sign)', function(){
@@ -983,12 +1063,12 @@ describe('moneyParse', function(){
983
1063
  assert.equal(1222000.1, parseMoney("1 222 000.10"));
984
1064
  });
985
1065
 
986
- it('" -1 222 000.10" should be parsed as -1222000.1 (negative amount)', function(){
987
- assert.equal(-1222000.1, parseMoney(" -1 222 000.10"));
1066
+ it('"- 1 222 000.10" should be parsed as -1222000.1 (negative amount)', function(){
1067
+ assert.equal(-1222000.1, parseMoney("- 1 222 000.10"));
988
1068
  });
989
1069
 
990
- it('"1 222 0o0.10" should be parsed as 1222000.1 (with O instead of 0)', function(){
991
- assert.equal(1222000.1, parseMoney("1 222 0o0.10"));
1070
+ it('"1 222 o00.10" should be parsed as 1222000.1 (with O instead of 0)', function(){
1071
+ assert.equal(1222000.1, parseMoney("1 222 o00.10"));
992
1072
  });
993
1073
 
994
1074
  it('"$1 222 000.10" should be parsed as 1222000.1 (with a dollar sign)', function(){
@@ -1011,8 +1091,8 @@ describe('moneyParse', function(){
1011
1091
  assert.equal(1222000.1, parseMoney("1 222 000,10"));
1012
1092
  });
1013
1093
 
1014
- it('" -1 222 000,10" should be parsed as -1222000.1 (negative amount)', function(){
1015
- assert.equal(-1222000.1, parseMoney(" -1 222 000,10"));
1094
+ it('"-1 222 000,10" should be parsed as -1222000.1 (negative amount)', function(){
1095
+ assert.equal(-1222000.1, parseMoney("-1 222 000,10"));
1016
1096
  });
1017
1097
 
1018
1098
  it('"1 222 o00,10" should be parsed as 1222000.1 (with O instead of 0)', function(){
@@ -1039,12 +1119,12 @@ describe('moneyParse', function(){
1039
1119
  assert.equal(1222000.0, parseMoney("1 222 000"));
1040
1120
  });
1041
1121
 
1042
- it('"-1 222 000" should be parsed as -1222000.0 (negative amount)', function(){
1043
- assert.equal(-1222000.0, parseMoney("-1 222 000"));
1122
+ it('" -1 222 000" should be parsed as -1222000.0 (negative amount)', function(){
1123
+ assert.equal(-1222000.0, parseMoney(" -1 222 000"));
1044
1124
  });
1045
1125
 
1046
- it('"1 222 o00" should be parsed as 1222000.0 (with O instead of 0)', function(){
1047
- assert.equal(1222000.0, parseMoney("1 222 o00"));
1126
+ it('"1 222 0o0" should be parsed as 1222000.0 (with O instead of 0)', function(){
1127
+ assert.equal(1222000.0, parseMoney("1 222 0o0"));
1048
1128
  });
1049
1129
 
1050
1130
  it('"$1 222 000" should be parsed as 1222000.0 (with a dollar sign)', function(){
@@ -1067,12 +1147,12 @@ describe('moneyParse', function(){
1067
1147
  assert.equal(1222000.0, parseMoney("1 222 000"));
1068
1148
  });
1069
1149
 
1070
- it('"- 1 222 000" should be parsed as -1222000.0 (negative amount)', function(){
1071
- assert.equal(-1222000.0, parseMoney("- 1 222 000"));
1150
+ it('" -1 222 000" should be parsed as -1222000.0 (negative amount)', function(){
1151
+ assert.equal(-1222000.0, parseMoney(" -1 222 000"));
1072
1152
  });
1073
1153
 
1074
- it('"1 222 00o" should be parsed as 1222000.0 (with O instead of 0)', function(){
1075
- assert.equal(1222000.0, parseMoney("1 222 00o"));
1154
+ it('"1 222 o00" should be parsed as 1222000.0 (with O instead of 0)', function(){
1155
+ assert.equal(1222000.0, parseMoney("1 222 o00"));
1076
1156
  });
1077
1157
 
1078
1158
  it('"$1 222 000" should be parsed as 1222000.0 (with a dollar sign)', function(){
@@ -1095,12 +1175,12 @@ describe('moneyParse', function(){
1095
1175
  assert.equal(1222000.0, parseMoney("1,222,000"));
1096
1176
  });
1097
1177
 
1098
- it('" - 1,222,000" should be parsed as -1222000.0 (negative amount)', function(){
1099
- assert.equal(-1222000.0, parseMoney(" - 1,222,000"));
1178
+ it('" -1,222,000" should be parsed as -1222000.0 (negative amount)', function(){
1179
+ assert.equal(-1222000.0, parseMoney(" -1,222,000"));
1100
1180
  });
1101
1181
 
1102
- it('"1,222,0o0" should be parsed as 1222000.0 (with O instead of 0)', function(){
1103
- assert.equal(1222000.0, parseMoney("1,222,0o0"));
1182
+ it('"1,222,o00" should be parsed as 1222000.0 (with O instead of 0)', function(){
1183
+ assert.equal(1222000.0, parseMoney("1,222,o00"));
1104
1184
  });
1105
1185
 
1106
1186
  it('"$1,222,000" should be parsed as 1222000.0 (with a dollar sign)', function(){
@@ -1127,8 +1207,8 @@ describe('moneyParse', function(){
1127
1207
  assert.equal(-1222000.0, parseMoney(" -1.222.000"));
1128
1208
  });
1129
1209
 
1130
- it('"1.222.o00" should be parsed as 1222000.0 (with O instead of 0)', function(){
1131
- assert.equal(1222000.0, parseMoney("1.222.o00"));
1210
+ it('"1.222.00o" should be parsed as 1222000.0 (with O instead of 0)', function(){
1211
+ assert.equal(1222000.0, parseMoney("1.222.00o"));
1132
1212
  });
1133
1213
 
1134
1214
  it('"$1.222.000" should be parsed as 1222000.0 (with a dollar sign)', function(){
@@ -1151,12 +1231,12 @@ describe('moneyParse', function(){
1151
1231
  assert.equal(1222000.0, parseMoney("1 222 000"));
1152
1232
  });
1153
1233
 
1154
- it('" -1 222 000" should be parsed as -1222000.0 (negative amount)', function(){
1155
- assert.equal(-1222000.0, parseMoney(" -1 222 000"));
1234
+ it('"- 1 222 000" should be parsed as -1222000.0 (negative amount)', function(){
1235
+ assert.equal(-1222000.0, parseMoney("- 1 222 000"));
1156
1236
  });
1157
1237
 
1158
- it('"1 222 o00" should be parsed as 1222000.0 (with O instead of 0)', function(){
1159
- assert.equal(1222000.0, parseMoney("1 222 o00"));
1238
+ it('"1 222 0o0" should be parsed as 1222000.0 (with O instead of 0)', function(){
1239
+ assert.equal(1222000.0, parseMoney("1 222 0o0"));
1160
1240
  });
1161
1241
 
1162
1242
  it('"$1 222 000" should be parsed as 1222000.0 (with a dollar sign)', function(){
@@ -1179,8 +1259,8 @@ describe('moneyParse', function(){
1179
1259
  assert.equal(1222000.0, parseMoney("1 222 000"));
1180
1260
  });
1181
1261
 
1182
- it('"- 1 222 000" should be parsed as -1222000.0 (negative amount)', function(){
1183
- assert.equal(-1222000.0, parseMoney("- 1 222 000"));
1262
+ it('" - 1 222 000" should be parsed as -1222000.0 (negative amount)', function(){
1263
+ assert.equal(-1222000.0, parseMoney(" - 1 222 000"));
1184
1264
  });
1185
1265
 
1186
1266
  it('"1 222 00o" should be parsed as 1222000.0 (with O instead of 0)', function(){
@@ -1207,8 +1287,8 @@ describe('moneyParse', function(){
1207
1287
  assert.equal(2123.0, parseMoney("2,123"));
1208
1288
  });
1209
1289
 
1210
- it('"- 2,123" should be parsed as -2123.0 (negative amount)', function(){
1211
- assert.equal(-2123.0, parseMoney("- 2,123"));
1290
+ it('" - 2,123" should be parsed as -2123.0 (negative amount)', function(){
1291
+ assert.equal(-2123.0, parseMoney(" - 2,123"));
1212
1292
  });
1213
1293
 
1214
1294
  it('"$2,123" should be parsed as 2123.0 (with a dollar sign)', function(){
@@ -1299,8 +1379,8 @@ describe('moneyParse', function(){
1299
1379
  assert.equal(1.0, parseMoney("1"));
1300
1380
  });
1301
1381
 
1302
- it('" - 1" should be parsed as -1.0 (negative amount)', function(){
1303
- assert.equal(-1.0, parseMoney(" - 1"));
1382
+ it('"-1" should be parsed as -1.0 (negative amount)', function(){
1383
+ assert.equal(-1.0, parseMoney("-1"));
1304
1384
  });
1305
1385
 
1306
1386
  it('"$1" should be parsed as 1.0 (with a dollar sign)', function(){
@@ -30,6 +30,9 @@ parseMoney = function(moneyString){
30
30
  if (chunks.length == 1){
31
31
  normalized = cleanedUp;
32
32
  }else{
33
+ if (! chunks[chunks.length - 1]){
34
+ return;
35
+ }
33
36
  if (chunks[chunks.length - 1].length > 2){
34
37
  normalized = chunks.join("")
35
38
  }else{