blob: f1449f6ba4f891b161706794487bea03e381a9cc [file] [log] [blame]
Steve Blocka7e24c12009-10-30 11:49:00 +00001// Copyright 2009 the V8 project authors. All rights reserved.
2// Redistribution and use in source and binary forms, with or without
3// modification, are permitted provided that the following conditions are
4// met:
5//
6// * Redistributions of source code must retain the above copyright
7// notice, this list of conditions and the following disclaimer.
8// * Redistributions in binary form must reproduce the above
9// copyright notice, this list of conditions and the following
10// disclaimer in the documentation and/or other materials provided
11// with the distribution.
12// * Neither the name of Google Inc. nor the names of its
13// contributors may be used to endorse or promote products derived
14// from this software without specific prior written permission.
15//
16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28// Load CSV parser implementation from <project root>/tools.
29// Files: tools/csvparser.js
30
Steve Block1e0659c2011-05-24 12:43:12 +010031var parser = new CsvParser();
Steve Blocka7e24c12009-10-30 11:49:00 +000032
33assertEquals(
34 [],
35 parser.parseLine(''));
36
37assertEquals(
38 ['', ''],
39 parser.parseLine(','));
40
41assertEquals(
42 ['1997','Ford','E350'],
43 parser.parseLine('1997,Ford,E350'));
44
45assertEquals(
46 ['1997','Ford','E350'],
47 parser.parseLine('"1997","Ford","E350"'));
48
49assertEquals(
50 ['1997','Ford','E350','Super, luxurious truck'],
51 parser.parseLine('1997,Ford,E350,"Super, luxurious truck"'));
52
53assertEquals(
54 ['1997','Ford','E350','Super "luxurious" truck'],
55 parser.parseLine('1997,Ford,E350,"Super ""luxurious"" truck"'));
56
57assertEquals(
58 ['1997','Ford','E350','Super "luxurious" "truck"'],
59 parser.parseLine('1997,Ford,E350,"Super ""luxurious"" ""truck"""'));
60
61assertEquals(
62 ['1997','Ford','E350','Super "luxurious""truck"'],
63 parser.parseLine('1997,Ford,E350,"Super ""luxurious""""truck"""'));
64
65assertEquals(
66 ['shared-library','/lib/ld-2.3.6.so','0x489a2000','0x489b7000'],
67 parser.parseLine('shared-library,"/lib/ld-2.3.6.so",0x489a2000,0x489b7000'));
68
69assertEquals(
70 ['code-creation','LazyCompile','0xf6fe2d20','1201','APPLY_PREPARE native runtime.js:165'],
71 parser.parseLine('code-creation,LazyCompile,0xf6fe2d20,1201,"APPLY_PREPARE native runtime.js:165"'));
72
73assertEquals(
74 ['code-creation','LazyCompile','0xf6fe4bc0','282',' native v8natives.js:69'],
75 parser.parseLine('code-creation,LazyCompile,0xf6fe4bc0,282," native v8natives.js:69"'));
76
77assertEquals(
78 ['code-creation','RegExp','0xf6c21c00','826','NccyrJroXvg\\/([^,]*)'],
79 parser.parseLine('code-creation,RegExp,0xf6c21c00,826,"NccyrJroXvg\\/([^,]*)"'));
Leon Clarke4515c472010-02-03 11:58:03 +000080
81assertEquals(
82 ['code-creation','Function','0x42f0a0','163',''],
83 parser.parseLine('code-creation,Function,0x42f0a0,163,""'));