Support prefix notation for vstore strings. Closes #2906.
This commit is contained in:
parent
e4de160222
commit
985b52be6d
46 changed files with 252 additions and 237 deletions
|
|
@ -659,8 +659,8 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_write_str() {
|
||||
assert to_str(string(@"")) == "\"\"";
|
||||
assert to_str(string(@"foo")) == "\"foo\"";
|
||||
assert to_str(string(@""/~)) == "\"\""/~;
|
||||
assert to_str(string(@"foo"/~)) == "\"foo\""/~;
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -676,7 +676,7 @@ mod tests {
|
|||
assert to_str(list(@~[
|
||||
boolean(false),
|
||||
null,
|
||||
list(@~[string(@"foo\nbar"), num(3.5f)])
|
||||
list(@~[string(@"foo\nbar"/~), num(3.5f)])
|
||||
])) == "[false, null, [\"foo\\nbar\", 3.5]]";
|
||||
}
|
||||
|
||||
|
|
@ -687,8 +687,8 @@ mod tests {
|
|||
assert to_str(mk_dict(~[
|
||||
("a", boolean(true)),
|
||||
("b", list(@~[
|
||||
mk_dict(~[("c", string(@"\x0c\r"))]),
|
||||
mk_dict(~[("d", string(@""))])
|
||||
mk_dict(~[("c", string(@"\x0c\r"/~))]),
|
||||
mk_dict(~[("d", string(@""/~))])
|
||||
]))
|
||||
])) ==
|
||||
"{ " +
|
||||
|
|
@ -703,35 +703,35 @@ mod tests {
|
|||
#[test]
|
||||
fn test_trailing_characters() {
|
||||
assert from_str("nulla") ==
|
||||
err({line: 1u, col: 5u, msg: @"trailing characters"});
|
||||
err({line: 1u, col: 5u, msg: @"trailing characters"/~});
|
||||
assert from_str("truea") ==
|
||||
err({line: 1u, col: 5u, msg: @"trailing characters"});
|
||||
err({line: 1u, col: 5u, msg: @"trailing characters"/~});
|
||||
assert from_str("falsea") ==
|
||||
err({line: 1u, col: 6u, msg: @"trailing characters"});
|
||||
err({line: 1u, col: 6u, msg: @"trailing characters"/~});
|
||||
assert from_str("1a") ==
|
||||
err({line: 1u, col: 2u, msg: @"trailing characters"});
|
||||
err({line: 1u, col: 2u, msg: @"trailing characters"/~});
|
||||
assert from_str("[]a") ==
|
||||
err({line: 1u, col: 3u, msg: @"trailing characters"});
|
||||
err({line: 1u, col: 3u, msg: @"trailing characters"/~});
|
||||
assert from_str("{}a") ==
|
||||
err({line: 1u, col: 3u, msg: @"trailing characters"});
|
||||
err({line: 1u, col: 3u, msg: @"trailing characters"/~});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_read_identifiers() {
|
||||
assert from_str("n") ==
|
||||
err({line: 1u, col: 2u, msg: @"invalid syntax"});
|
||||
err({line: 1u, col: 2u, msg: @"invalid syntax"/~});
|
||||
assert from_str("nul") ==
|
||||
err({line: 1u, col: 4u, msg: @"invalid syntax"});
|
||||
err({line: 1u, col: 4u, msg: @"invalid syntax"/~});
|
||||
|
||||
assert from_str("t") ==
|
||||
err({line: 1u, col: 2u, msg: @"invalid syntax"});
|
||||
err({line: 1u, col: 2u, msg: @"invalid syntax"/~});
|
||||
assert from_str("truz") ==
|
||||
err({line: 1u, col: 4u, msg: @"invalid syntax"});
|
||||
err({line: 1u, col: 4u, msg: @"invalid syntax"/~});
|
||||
|
||||
assert from_str("f") ==
|
||||
err({line: 1u, col: 2u, msg: @"invalid syntax"});
|
||||
err({line: 1u, col: 2u, msg: @"invalid syntax"/~});
|
||||
assert from_str("faz") ==
|
||||
err({line: 1u, col: 3u, msg: @"invalid syntax"});
|
||||
err({line: 1u, col: 3u, msg: @"invalid syntax"/~});
|
||||
|
||||
assert from_str("null") == ok(null);
|
||||
assert from_str("true") == ok(boolean(true));
|
||||
|
|
@ -744,20 +744,20 @@ mod tests {
|
|||
#[test]
|
||||
fn test_read_num() {
|
||||
assert from_str("+") ==
|
||||
err({line: 1u, col: 1u, msg: @"invalid syntax"});
|
||||
err({line: 1u, col: 1u, msg: @"invalid syntax"/~});
|
||||
assert from_str(".") ==
|
||||
err({line: 1u, col: 1u, msg: @"invalid syntax"});
|
||||
err({line: 1u, col: 1u, msg: @"invalid syntax"/~});
|
||||
|
||||
assert from_str("-") ==
|
||||
err({line: 1u, col: 2u, msg: @"invalid number"});
|
||||
err({line: 1u, col: 2u, msg: @"invalid number"/~});
|
||||
assert from_str("00") ==
|
||||
err({line: 1u, col: 2u, msg: @"invalid number"});
|
||||
err({line: 1u, col: 2u, msg: @"invalid number"/~});
|
||||
assert from_str("1.") ==
|
||||
err({line: 1u, col: 3u, msg: @"invalid number"});
|
||||
err({line: 1u, col: 3u, msg: @"invalid number"/~});
|
||||
assert from_str("1e") ==
|
||||
err({line: 1u, col: 3u, msg: @"invalid number"});
|
||||
err({line: 1u, col: 3u, msg: @"invalid number"/~});
|
||||
assert from_str("1e+") ==
|
||||
err({line: 1u, col: 4u, msg: @"invalid number"});
|
||||
err({line: 1u, col: 4u, msg: @"invalid number"/~});
|
||||
|
||||
assert from_str("3") == ok(num(3f));
|
||||
assert from_str("3.1") == ok(num(3.1f));
|
||||
|
|
@ -772,32 +772,32 @@ mod tests {
|
|||
#[test]
|
||||
fn test_read_str() {
|
||||
assert from_str("\"") ==
|
||||
err({line: 1u, col: 2u, msg: @"EOF while parsing string"});
|
||||
err({line: 1u, col: 2u, msg: @"EOF while parsing string"/~});
|
||||
assert from_str("\"lol") ==
|
||||
err({line: 1u, col: 5u, msg: @"EOF while parsing string"});
|
||||
err({line: 1u, col: 5u, msg: @"EOF while parsing string"/~});
|
||||
|
||||
assert from_str("\"\"") == ok(string(@""));
|
||||
assert from_str("\"foo\"") == ok(string(@"foo"));
|
||||
assert from_str("\"\\\"\"") == ok(string(@"\""));
|
||||
assert from_str("\"\\b\"") == ok(string(@"\x08"));
|
||||
assert from_str("\"\\n\"") == ok(string(@"\n"));
|
||||
assert from_str("\"\\r\"") == ok(string(@"\r"));
|
||||
assert from_str("\"\\t\"") == ok(string(@"\t"));
|
||||
assert from_str(" \"foo\" ") == ok(string(@"foo"));
|
||||
assert from_str("\"\"") == ok(string(@""/~));
|
||||
assert from_str("\"foo\"") == ok(string(@"foo"/~));
|
||||
assert from_str("\"\\\"\"") == ok(string(@"\""/~));
|
||||
assert from_str("\"\\b\"") == ok(string(@"\x08"/~));
|
||||
assert from_str("\"\\n\"") == ok(string(@"\n"/~));
|
||||
assert from_str("\"\\r\"") == ok(string(@"\r"/~));
|
||||
assert from_str("\"\\t\"") == ok(string(@"\t"/~));
|
||||
assert from_str(" \"foo\" ") == ok(string(@"foo"/~));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_read_list() {
|
||||
assert from_str("[") ==
|
||||
err({line: 1u, col: 2u, msg: @"EOF while parsing value"});
|
||||
err({line: 1u, col: 2u, msg: @"EOF while parsing value"/~});
|
||||
assert from_str("[1") ==
|
||||
err({line: 1u, col: 3u, msg: @"EOF while parsing list"});
|
||||
err({line: 1u, col: 3u, msg: @"EOF while parsing list"/~});
|
||||
assert from_str("[1,") ==
|
||||
err({line: 1u, col: 4u, msg: @"EOF while parsing value"});
|
||||
err({line: 1u, col: 4u, msg: @"EOF while parsing value"/~});
|
||||
assert from_str("[1,]") ==
|
||||
err({line: 1u, col: 4u, msg: @"invalid syntax"});
|
||||
err({line: 1u, col: 4u, msg: @"invalid syntax"/~});
|
||||
assert from_str("[6 7]") ==
|
||||
err({line: 1u, col: 4u, msg: @"expected `,` or `]`"});
|
||||
err({line: 1u, col: 4u, msg: @"expected `,` or `]`"/~});
|
||||
|
||||
assert from_str("[]") == ok(list(@~[]));
|
||||
assert from_str("[ ]") == ok(list(@~[]));
|
||||
|
|
@ -813,28 +813,28 @@ mod tests {
|
|||
#[test]
|
||||
fn test_read_dict() {
|
||||
assert from_str("{") ==
|
||||
err({line: 1u, col: 2u, msg: @"EOF while parsing object"});
|
||||
err({line: 1u, col: 2u, msg: @"EOF while parsing object"/~});
|
||||
assert from_str("{ ") ==
|
||||
err({line: 1u, col: 3u, msg: @"EOF while parsing object"});
|
||||
err({line: 1u, col: 3u, msg: @"EOF while parsing object"/~});
|
||||
assert from_str("{1") ==
|
||||
err({line: 1u, col: 2u, msg: @"key must be a string"});
|
||||
err({line: 1u, col: 2u, msg: @"key must be a string"/~});
|
||||
assert from_str("{ \"a\"") ==
|
||||
err({line: 1u, col: 6u, msg: @"EOF while parsing object"});
|
||||
err({line: 1u, col: 6u, msg: @"EOF while parsing object"/~});
|
||||
assert from_str("{\"a\"") ==
|
||||
err({line: 1u, col: 5u, msg: @"EOF while parsing object"});
|
||||
err({line: 1u, col: 5u, msg: @"EOF while parsing object"/~});
|
||||
assert from_str("{\"a\" ") ==
|
||||
err({line: 1u, col: 6u, msg: @"EOF while parsing object"});
|
||||
err({line: 1u, col: 6u, msg: @"EOF while parsing object"/~});
|
||||
|
||||
assert from_str("{\"a\" 1") ==
|
||||
err({line: 1u, col: 6u, msg: @"expected `:`"});
|
||||
err({line: 1u, col: 6u, msg: @"expected `:`"/~});
|
||||
assert from_str("{\"a\":") ==
|
||||
err({line: 1u, col: 6u, msg: @"EOF while parsing value"});
|
||||
err({line: 1u, col: 6u, msg: @"EOF while parsing value"/~});
|
||||
assert from_str("{\"a\":1") ==
|
||||
err({line: 1u, col: 7u, msg: @"EOF while parsing object"});
|
||||
err({line: 1u, col: 7u, msg: @"EOF while parsing object"/~});
|
||||
assert from_str("{\"a\":1 1") ==
|
||||
err({line: 1u, col: 8u, msg: @"expected `,` or `}`"});
|
||||
err({line: 1u, col: 8u, msg: @"expected `,` or `}`"/~});
|
||||
assert from_str("{\"a\":1,") ==
|
||||
err({line: 1u, col: 8u, msg: @"EOF while parsing object"});
|
||||
err({line: 1u, col: 8u, msg: @"EOF while parsing object"/~});
|
||||
|
||||
assert eq(result::get(from_str("{}")), mk_dict(~[]));
|
||||
assert eq(result::get(from_str("{\"a\": 3}")),
|
||||
|
|
@ -866,7 +866,7 @@ mod tests {
|
|||
("a", num(1.0f)),
|
||||
("b", list(@~[
|
||||
boolean(true),
|
||||
string(@"foo\nbar"),
|
||||
string(@"foo\nbar"/~),
|
||||
mk_dict(~[
|
||||
("c", mk_dict(~[("d", null)]))
|
||||
])
|
||||
|
|
@ -877,6 +877,6 @@ mod tests {
|
|||
#[test]
|
||||
fn test_multiline_errors() {
|
||||
assert from_str("{\n \"foo\":\n \"bar\"") ==
|
||||
err({line: 3u, col: 8u, msg: @"EOF while parsing object"});
|
||||
err({line: 3u, col: 8u, msg: @"EOF while parsing object"/~});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1270,7 +1270,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn of_string1() {
|
||||
let sample = @"0123456789ABCDE";
|
||||
let sample = @"0123456789ABCDE"/~;
|
||||
let r = of_str(sample);
|
||||
|
||||
assert char_len(r) == str::char_len(*sample);
|
||||
|
|
@ -1330,8 +1330,8 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn bal1() {
|
||||
let init = @ "1234567890";
|
||||
let buf = @ mut * init;
|
||||
let init = @"1234567890"/~;
|
||||
let buf = @mut * init;
|
||||
let mut i = 0;
|
||||
while i < 8 { *buf = *buf + *buf; i+=1;}
|
||||
let sample = @*buf;
|
||||
|
|
@ -1352,7 +1352,7 @@ mod tests {
|
|||
#[ignore]
|
||||
fn char_at1() {
|
||||
//Generate a large rope
|
||||
let mut r = of_str(@ "123456789");
|
||||
let mut r = of_str(@"123456789"/~);
|
||||
for uint::range(0u, 10u) |_i| {
|
||||
r = append_rope(r, r);
|
||||
}
|
||||
|
|
@ -1384,7 +1384,7 @@ mod tests {
|
|||
#[test]
|
||||
fn concat1() {
|
||||
//Generate a reasonable rope
|
||||
let chunk = of_str(@ "123456789");
|
||||
let chunk = of_str(@"123456789"/~);
|
||||
let mut r = empty();
|
||||
for uint::range(0u, 10u) |_i| {
|
||||
r = append_rope(r, chunk);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue