* Improve imports
* Nonexistent file is now a runtime error (used to be ignored)
* Permission denied is a runtime error (used to be an internal error)
* Basic tests added for imports
* Renamed tests from .input to .jsonnet
* It's standard
* It's compatible with C++ test suite
* Editors enable syntax highlighting based on extension
* Importing .input looks weird
Fix a bunch of bugs:
- Reverse meaning of boolean argument to objectFieldsEx and objectHasEx
- Slice desugaring using `std.slice` instead of `slice` as a field name.
Support + on string and something else.
Support + on arrays
assertEqual should now work properly
* Array comprehensions
Implemented using flatMap.
The representation in AST was changed - now it expresses
the semantic structure better.
Ifs in comprehensions are not supported yet, but easy.
* Interpreter & runtime - minimal usable version
Accomplishments in this commit:
* Majority of language features implemented:
* Unary operators
* Binary operators
* Conditionals
* Errors
* Indexing arrays
* Indexing objects
* Object inheritance
* Imports
* Functions
* Function calls
* There is a quite nice way for creating builtins
* Static analyzer is there with most of the functionality
* Standard library is included and parts unaffected by missing features
work
* Some bugs in existing parts fixed
* Most positive tests from C++ version pass, the rest is failing mostly
due to missing builtins and comprehensions.
* Some initial structure was created that should allow more incremental
and focused changes in the future PRs.
* Some comments/explanations added
* Panics translated to a little bit more gentle internal errors (with a
link to issues on github).
What still sucks:
* Stack traces & error messages (there's some stuff in place)
* Almost everything is in the same package
* Stuff is exported or unexporeted randomly (see above)
* Missing a few lexing/parsing features
* Missing builtins
* Missing support for extvars and top-level-args
* Checking function arguments is missing
* No clean Go API that commandline and compatibility layer to C can use
* No compatibility layer to C
* Assertions don't work (desugaring level, assertEquals works).
* Manifestation stack traces (and generally it could use some work).
* The way environments are constructed is sometimes suboptimal/clumsy.
this commit proposes using a file based golden tests approach,
parts of this refactor uses code and conventions from the go std
library. At it's current state go-jsonnet does not support many of
the examples on http://jsonnet.org/docs/demo.html, motive behind
the refactor is to add the demo examples to the test suite and
the demo examples are too big to be inlined.
Signed-off-by: Sevki <s@sevki.org>
since non of the test cases actually use the err string field and
the golden file testing pattern does not really need it, this commit
proposes the removal of the errString field from tests
Signed-off-by: Sevki <s@sevki.org>
using `t.Run` instead including the test name in error message is
a more idiomatic way of testing things in go. Since this feature
was added to go in 1.7 release and the travis config explicitly
specifies 1.4 and 1.5 (2 and 2,5 year old releases) as test targets
this change will break the CI builds, therefore this commit also
proposes dropping those releases in favour of adding a newer
version of go (1.8) as the test target.
Signed-off-by: Sevki <s@sevki.org>
Given the following scenario
vm := jsonnet.MakeVM()
vm.ExtVar("foo", "bar")
calling the `ExtVar` and `ExtCode` methods of a vm result in a panic
because the map has not been initialized, this patch adds
initializes the map.
Signed-off-by: Sevki <s@sevki.org>
* New features in parser and desugarer
Support for slices
Support for methods
Support for function sugar in locals
Prevent crashes with obj/arr comprehensions
After this change evaluating stdlib doesn't crash.