From 45245e05b682d766c12e5cbb9c0e600aafbf3dfe Mon Sep 17 00:00:00 2001 From: Maurice Makaay Date: Wed, 19 Jun 2019 11:09:26 +0000 Subject: [PATCH] Some small cleanup, committing before I continue with inline lists. --- keyvaluepair_test.go | 4 ++-- value_datetime.go | 4 ++-- value_datetime_test.go | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/keyvaluepair_test.go b/keyvaluepair_test.go index eb328f0..c18c98f 100644 --- a/keyvaluepair_test.go +++ b/keyvaluepair_test.go @@ -123,9 +123,9 @@ func TestKeyValuePair_ExamplesFromSpecification(t *testing.T) { {"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")`}}, {"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`\")"}}, - {"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)`}}, {"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)`}}, diff --git a/value_datetime.go b/value_datetime.go index 33dd40f..be2f186 100644 --- a/value_datetime.go +++ b/value_datetime.go @@ -34,12 +34,12 @@ var ( hhmmss = c.Seq(hour, a.Colon, minute, a.Colon, seconds) 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 // precision than the implementation can support, the additional precision // must be truncated, not rounded. 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 // date and time with a space (as permitted by RFC 3339 section 5.6). diff --git a/value_datetime_test.go b/value_datetime_test.go index 9d6e322..553a4f2 100644 --- a/value_datetime_test.go +++ b/value_datetime_test.go @@ -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)`}}, {`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)`}}, + {`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)`}}, // 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`}},