mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
compiler: generalize mod dag & use for sorting structs also
This commit is contained in:

committed by
Alexander Medvednikov

parent
db110759ab
commit
b4d033ff54
@ -1,41 +1,40 @@
|
||||
// Skip this test until struct field order bug is fixed
|
||||
// import encoding.csv
|
||||
import encoding.csv
|
||||
|
||||
// fn test_encoding_csv_reader() {
|
||||
// data := 'name,email,phone,other\njoe,joe@blow.com,0400000000,test\nsam,sam@likesham.com,0433000000,"test quoted field"\n#chris,chris@nomail.com,94444444,"commented row"\nmike,mike@mikesbikes.com,98888888,"bike store"\n'
|
||||
// mut csv_reader := csv.new_reader(data)
|
||||
fn test_encoding_csv_reader() {
|
||||
data := 'name,email,phone,other\njoe,joe@blow.com,0400000000,test\nsam,sam@likesham.com,0433000000,"test quoted field"\n#chris,chris@nomail.com,94444444,"commented row"\nmike,mike@mikesbikes.com,98888888,"bike store"\n'
|
||||
mut csv_reader := csv.new_reader(data)
|
||||
|
||||
// mut row_count := 0
|
||||
// for {
|
||||
// row := csv_reader.read() or {
|
||||
// break
|
||||
// }
|
||||
// row_count++
|
||||
// if row_count== 1 {
|
||||
// assert row[0] == 'name'
|
||||
// }
|
||||
// if row_count == 2 {
|
||||
// assert row[0] == 'joe'
|
||||
// }
|
||||
// if row_count == 3 {
|
||||
// assert row[0] == 'sam'
|
||||
// // quoted field
|
||||
// assert row[3] == 'test quoted field'
|
||||
// }
|
||||
// if row_count == 4 {
|
||||
// assert row[0] == 'mike'
|
||||
// }
|
||||
// }
|
||||
mut row_count := 0
|
||||
for {
|
||||
row := csv_reader.read() or {
|
||||
break
|
||||
}
|
||||
row_count++
|
||||
if row_count== 1 {
|
||||
assert row[0] == 'name'
|
||||
}
|
||||
if row_count == 2 {
|
||||
assert row[0] == 'joe'
|
||||
}
|
||||
if row_count == 3 {
|
||||
assert row[0] == 'sam'
|
||||
// quoted field
|
||||
assert row[3] == 'test quoted field'
|
||||
}
|
||||
if row_count == 4 {
|
||||
assert row[0] == 'mike'
|
||||
}
|
||||
}
|
||||
|
||||
// assert row_count == 4
|
||||
// }
|
||||
assert row_count == 4
|
||||
}
|
||||
|
||||
// fn test_encoding_csv_writer() {
|
||||
// mut csv_writer := csv.new_writer()
|
||||
fn test_encoding_csv_writer() {
|
||||
mut csv_writer := csv.new_writer()
|
||||
|
||||
// csv_writer.write(['name', 'email', 'phone', 'other'])
|
||||
// csv_writer.write(['joe', 'joe@blow.com', '0400000000', 'test'])
|
||||
// csv_writer.write(['sam', 'sam@likesham.com', '0433000000', 'needs, quoting'])
|
||||
csv_writer.write(['name', 'email', 'phone', 'other'])
|
||||
csv_writer.write(['joe', 'joe@blow.com', '0400000000', 'test'])
|
||||
csv_writer.write(['sam', 'sam@likesham.com', '0433000000', 'needs, quoting'])
|
||||
|
||||
// assert csv_writer.str() == 'name,email,phone,other\njoe,joe@blow.com,0400000000,test\nsam,sam@likesham.com,0433000000,"needs, quoting"\n'
|
||||
// }
|
||||
assert csv_writer.str() == 'name,email,phone,other\njoe,joe@blow.com,0400000000,test\nsam,sam@likesham.com,0433000000,"needs, quoting"\n'
|
||||
}
|
||||
|
Reference in New Issue
Block a user