Some small cleanup, committing before I continue with inline lists.
This commit is contained in:
parent
c405260ea6
commit
45245e05b6
|
@ -123,9 +123,9 @@ func TestKeyValuePair_ExamplesFromSpecification(t *testing.T) {
|
||||||
{"sf1 = inf # positive infinity", []string{`key("sf1")`, `assign`, `float(+Inf)`, `comment("# positive infinity")`}},
|
{"sf1 = inf # positive infinity", []string{`key("sf1")`, `assign`, `float(+Inf)`, `comment("# positive infinity")`}},
|
||||||
{"sf2 = +inf # positive infinity", []string{`key("sf2")`, `assign`, `float(+Inf)`, `comment("# positive infinity")`}},
|
{"sf2 = +inf # positive infinity", []string{`key("sf2")`, `assign`, `float(+Inf)`, `comment("# positive infinity")`}},
|
||||||
{"sf3 = -inf # negative infinity", []string{`key("sf3")`, `assign`, `float(-Inf)`, `comment("# negative infinity")`}},
|
{"sf3 = -inf # negative infinity", []string{`key("sf3")`, `assign`, `float(-Inf)`, `comment("# negative infinity")`}},
|
||||||
{"sf4 = nan # actual sNaN/qNaN encoding is implementation specific", []string{`key("sf4")`, `assign`, `float(NaN)`, `comment("# actual sNaN/qNaN encoding is implementation specific")`}},
|
{"sf4 = nan # actual sNaN/qNaN encoding is implementation-specific", []string{`key("sf4")`, `assign`, `float(NaN)`, `comment("# actual sNaN/qNaN encoding is implementation-specific")`}},
|
||||||
{"sf5 = +nan # same as `nan`", []string{`key("sf5")`, `assign`, `float(NaN)`, "comment(\"# same as `nan`\")"}},
|
{"sf5 = +nan # same as `nan`", []string{`key("sf5")`, `assign`, `float(NaN)`, "comment(\"# same as `nan`\")"}},
|
||||||
{"sf6 = -nan # valid, actual encoding is implementation specific", []string{`key("sf6")`, `assign`, `float(NaN)`, `comment("# valid, actual encoding is implementation specific")`}},
|
{"sf6 = -nan # valid, actual encoding is implementation-specific", []string{`key("sf6")`, `assign`, `float(NaN)`, `comment("# valid, actual encoding is implementation-specific")`}},
|
||||||
{"bool1 = true", []string{`key("bool1")`, `assign`, `boolean(true)`}},
|
{"bool1 = true", []string{`key("bool1")`, `assign`, `boolean(true)`}},
|
||||||
{"bool2 = false", []string{`key("bool2")`, `assign`, `boolean(false)`}},
|
{"bool2 = false", []string{`key("bool2")`, `assign`, `boolean(false)`}},
|
||||||
{"odt1 = 1979-05-27T07:32:00Z", []string{`key("odt1")`, `assign`, `offset_datetime(1979-05-27 07:32:00 +0000 UTC)`}},
|
{"odt1 = 1979-05-27T07:32:00Z", []string{`key("odt1")`, `assign`, `offset_datetime(1979-05-27 07:32:00 +0000 UTC)`}},
|
||||||
|
|
|
@ -34,12 +34,12 @@ var (
|
||||||
hhmmss = c.Seq(hour, a.Colon, minute, a.Colon, seconds)
|
hhmmss = c.Seq(hour, a.Colon, minute, a.Colon, seconds)
|
||||||
timeTok = tok.Str("15:04:05", hhmmss)
|
timeTok = tok.Str("15:04:05", hhmmss)
|
||||||
|
|
||||||
// The precision of fractional seconds is implementation specific, but at
|
// The precision of fractional seconds is implementation-specific, but at
|
||||||
// least millisecond precision is expected. If the value contains greater
|
// least millisecond precision is expected. If the value contains greater
|
||||||
// precision than the implementation can support, the additional precision
|
// precision than the implementation can support, the additional precision
|
||||||
// must be truncated, not rounded.
|
// must be truncated, not rounded.
|
||||||
micro = a.Dot.Then(c.MinMax(1, 9, a.Digit).Then(m.Drop(c.ZeroOrMore(a.Digit))))
|
micro = a.Dot.Then(c.MinMax(1, 9, a.Digit).Then(m.Drop(c.ZeroOrMore(a.Digit))))
|
||||||
microTok = tok.Str(".999999999", micro.Optional())
|
microTok = c.Optional(tok.Str(".999999999", micro))
|
||||||
|
|
||||||
// For the sake of readability, you may replace the T delimiter between
|
// For the sake of readability, you may replace the T delimiter between
|
||||||
// date and time with a space (as permitted by RFC 3339 section 5.6).
|
// date and time with a space (as permitted by RFC 3339 section 5.6).
|
||||||
|
|
|
@ -20,6 +20,7 @@ func TestDateTime(t *testing.T) {
|
||||||
{`1985-03-31 23:59:59+00:00`, []string{`offset_datetime(1985-03-31 23:59:59 +0000 UTC)`}},
|
{`1985-03-31 23:59:59+00:00`, []string{`offset_datetime(1985-03-31 23:59:59 +0000 UTC)`}},
|
||||||
{`2000-09-10 00:00:00.000000000+00:00`, []string{`offset_datetime(2000-09-10 00:00:00 +0000 UTC)`}},
|
{`2000-09-10 00:00:00.000000000+00:00`, []string{`offset_datetime(2000-09-10 00:00:00 +0000 UTC)`}},
|
||||||
{`2003-11-01 01:02:03.999999999999+10:00`, []string{`offset_datetime(2003-11-01 01:02:03.999999999 +1000 +1000)`}},
|
{`2003-11-01 01:02:03.999999999999+10:00`, []string{`offset_datetime(2003-11-01 01:02:03.999999999 +1000 +1000)`}},
|
||||||
|
{`2007-12-25 04:00:04.1111-10:30`, []string{`offset_datetime(2007-12-25 04:00:04.1111 -1030 -1030)`}},
|
||||||
{`2021-02-01 10:10:10.101010203040Z`, []string{`offset_datetime(2021-02-01 10:10:10.101010203 +0000 UTC)`}},
|
{`2021-02-01 10:10:10.101010203040Z`, []string{`offset_datetime(2021-02-01 10:10:10.101010203 +0000 UTC)`}},
|
||||||
// TODO ugly column, should be at start or at the actual wrong part
|
// TODO ugly column, should be at start or at the actual wrong part
|
||||||
{`2000-13-01`, []string{`Error: Cannot parse value 02000-13-01: parsing time "2000-13-01": month out of range at line 1, column 11`}},
|
{`2000-13-01`, []string{`Error: Cannot parse value 02000-13-01: parsing time "2000-13-01": month out of range at line 1, column 11`}},
|
||||||
|
|
Loading…
Reference in New Issue