pkl.test0.28.1
- Module URI:
- pkl:testcontent_copy
- Pkl version:
- 0.28.1 or higher
- Known subtypes:
- Known usages:
- All versions:
- 0.29.0-dev, 0.28.1, 0.28.0, 0.28.0-dev, 0.27.2, 0.27.1, 0.27.0, 0.26.3, 0.26.2, 0.26.1, 0.26.0, 0.25.3, 0.25.2, 0.25.1, 0.25.0-dev
Properties(show inherited)
-
expand_morelinkhidden
The output of this module.
Defaults to all module properties rendered as either Pcf or the format specified on the command line.
-
expand_morelink
Named groups of boolean expressions that are expected to evaluate to
true
.If an expression evaluates to
false
, it is reported as a test failure.Example:
// for brevity, code under test is defined here function multiply(a, b) = a * b facts { ["multiply numbers"] { multiply(3, 5) == 15 multiple(3, 0) == 1 // will be reported as a test failure } // more facts here }
-
expand_morelink
Named groups of expressions whose results are expected to match results stored in $filename-expected.pcf.
If $filename-expected.pcf does not exist, it is generated based on the examples' actual results. After verifying the contents of this file, it should be added to version control.
If $filename-expected.pcf does exist, its results are compared one-by-one to actual results. If an actual result does not compare equal (according to
==
) to its expected result, it is reported as a test failure, and $filename-actual.pcf is generated to aid with debugging.Example:
// for brevity, code under test is defined here local function createPigeon(_age) = new { name = "Pigeon" age = _age } examples { ["create Pigeons"] { createPigeon(21) createPigeon(42) } // more examples here }
When the above code is evaluated for the first time, the following
$filename-expected.pcf
is generated:examples { ["create Pigeons"] { new { name = "Pigeon" age = 21 } new { name = "Pigeon" age = 42 } } }
To update expected results after making changes, delete $filename-expected.pcf and evaluate the test module again.
Methods(show inherited)
-
-
-
-
-
-
-
-
-
expand_morelinkfunction
Returns the relative, descendent directory path between this module and
other
.Throws if no such path exists.
For example, if module
mod1
has path/dir1/mod1.pkl
, and modulemod2
has path/dir1/dir2/dir3/mod2.pkl
, thenmod1.relativePathTo(mod2)
will returnList("dir2", "dir3")
.A common use case is to compute the directory path between a template located at the root of a hierarchy (say
rootModule.pkl
) and the currently evaluated module (accessible via themodule
keyword):import "rootModule.pkl" // self-import path = rootModule.relativePathTo(module)
-
-
A template for writing tests.