Skip to content
This repository has been archived by the owner on Feb 21, 2024. It is now read-only.

some AST and parser test coverage expansion #2378

Closed
wants to merge 2 commits into from
Closed

some AST and parser test coverage expansion #2378

wants to merge 2 commits into from

Conversation

seebs
Copy link
Contributor

@seebs seebs commented Apr 7, 2023

Now that we support function bodies, we add a test case or two for them, which reveal that we're not round-tripping, so we tweak things slightly to make that work. There's an open issue there with semicolon semantics that we should revisit once we allow more than one kind of trivial expression in function bodies.

Trying to figure out why the second case in time parsing never got evaluated, I discovered that it has no reason to exist. Took this as an excuse to standardize on a single time-parser that lives in one place and is used by everything else, which makes the code a bit shorter in most cases, and lets us be more confident that the semantics are always the same. This looks intrusive but it's actually pretty trivial.

Improves test coverage in ast.go and walk.go slightly, and might actually help slightly with some other files by removing lines of code that were actually unreachable but weren't obviously-unreachable until you spend ten minutes staring closely at the docs for the time package.

A naive test of a function with a body failed because we were
not actually looking for or accepting semicolons, but were generating
them on printing a thing back out. Changed to require semicolons
between statements. This logic may be wrong; for instance, if
you have a trailing semicolon on a body, the String() method won't
yield the original text exactly.
We had a bunch of different places which had basically the
same logic, except that some were testing both RFC3339Nano
and RFC3339 formats, and some weren't.

This turns out not to matter, because the fractional second
part is always permitted and never required, so those two
formats are identical.

Mostly, though, we now ensure that everything we do that is
trying to convert timestamps has the same logic, so if we
want to make changes to that logic, we have a central point,
which lives in the parser.

This came out of an attempt to figure out why the RFC3339
case wasn't getting any test coverage.
@seebs seebs requested a review from lorycloutier April 7, 2023 22:10
@sonarcloud
Copy link

sonarcloud bot commented Apr 7, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
19.1% 19.1% Duplication

@seebs
Copy link
Contributor Author

seebs commented May 24, 2023

this got merged in a different branch.

@seebs seebs closed this May 24, 2023
liuxisong pushed a commit to liuxisong/pilosa that referenced this pull request Jul 7, 2023
* FB-1814: Implement ASCII()

(cherry picked from commit f590227)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant