Commit Graph

15 Commits

Author SHA1 Message Date
Martin Atkins 7887810587 specsuite: Fix some regressions
Lately we've made some changes that have affected the behavior of the
specsuite tests, causing them to fail. Much of this was caused by changes
to the harness itself (based on hcldec), although one break in particular
here was an intentional change to the implementation of modulo in
upstream cty to make it produce a more accurate result when used with
a fractional divisor.
2021-02-23 09:05:19 -08:00
Martin Atkins 2eaeb36cb3 Use Unicode 13 text segmentation rules
HCL uses a number of upstream libraries that implement algorithms defined
in Unicode. This commit is updating those libraries all to versions that
have Unicode 13 support.

The main implication of this for HCL directly is that when it returns
column numbers in source locations it will count characters using the
Unicode 13 definition of "character", which includes various new
multi-codeunit characters added in Unicode 13.

These new version dependencies will also make Unicode 13 support available
for other functionality that HCL callers might use, such as the stdlib
functions in upstream cty, even though HCL itself does not directly use
those.
2021-02-23 09:05:19 -08:00
Masayuki Morita cec773f974 Fix various stale links to spec.md
These resulted from repository reorganization in preparation for the 2.0.0 release.
2020-01-09 11:02:20 -08:00
Martin Atkins ee38c67330 specsuite: Tests for the expression language operators 2019-10-01 15:59:10 -07:00
Martin Atkins 48fbad7bf4 specsuite: tests for primitive type literals 2019-10-01 15:59:10 -07:00
Martin Atkins 6c43130979 specsuite: Move the Go testing stub into the specsuite directory
The separate "spectests" directory was an artifact of our former nesting
of the main package under a "hcl" directory. However, it was confusing
to have both specsuite and spectests directories at the top level, so
instead we'll just conflate these two by putting the automatic Go testing
helper into the specsuite directory.
2019-10-01 15:59:10 -07:00
Martin Atkins 3327dee567 Change module path to github.com/hashicorp/hcl/v2
This is in preparation for the first v2 release from the main HCL
repository.
2019-09-09 15:46:40 -07:00
Aaron Gallagher 65731f3310 specsuite: tests for flush heredocs with empty lines 2019-08-05 16:24:22 -07:00
Martin Atkins bafa0c5ace hcl/hclsyntax: Accept single-line block definitions
This relaxes our previous spec to include a special form from HCL 1:

    foo { bar = baz }

Although we normally require each argument to be on a line of its own, as
a special case we allow a block to be defined with a single nested
argument all on one line.

Only one nested argument definition is allowed, and a nested block
definition like "foo { bar {} }" is also disallowed in order to force the
more-readable split of bar {} onto a line of its own.

This is a pragmatic addition for broader compatibility with HCL 1-oriented
input. This single-line usage is not considered idiomatic HCL 2 and may
in future be undone by the formatter, though for now it is left as-is
aside from the spacing around the braces.

This also changes the behavior of the source code formatter to include
spaces on both sides of braces. This mimicks the formatting behavior of
HCL 1 for this situation, and (subjectively) reads better even for other
one-line braced expressions like object constructors and object for
expressions.
2018-12-14 13:45:03 -08:00
Martin Atkins e8dbb16dbc hcl/hclsyntax: Fix up parsing of flush heredocs
This was implemented a long time ago in the original template parser, but
it was missed in the rewrite of the template parser to make it use a
two-stage parsing strategy.

It's implemented as a post-processing step on the result of the first
stage of parsing, which produces a flat sequence of literal strings,
interpolation markers, and control markers, and prior to the second stage
which matches opening and closing control markers to produce an expression
AST.

It's important to do this at parse time rather than eval time since it is
the static layout of the source code that decides the indentation level,
and so an interpolation marker at the start of a line that itself produces
spaces does not affect the result.
2018-12-13 17:22:41 -08:00
Martin Atkins 12f0f2dbc5 specsuite: a few additional tests for structure
This is still not fully comprehensive, but tests some basic functionality.
2018-08-12 18:18:58 -07:00
Martin Atkins a5c0f7fdcc cmd/hclspecsuite: Check for expected diagnostics
When a test file declares one or more expected diagnostics, we check those
instead of checking the result value. The severities and source ranges
must match.

We don't test the error messages themselves because they are not part of
the specification and may vary between implementations or, in future, be
translated into other languages.
2018-08-12 10:08:27 -07:00
Martin Atkins 65f9271b86 specsuite: Initial test for top-level attribute handling 2018-08-10 08:57:59 -07:00
Martin Atkins db04b3dffe specsuites: Tests for comment parsing 2018-08-10 08:51:51 -07:00
Martin Atkins 0956c193b7 specsuite: Start of the harness for the specification test suite 2018-08-09 19:29:32 -07:00