aboutsummaryrefslogtreecommitdiff
path: root/tests/function/builtin
AgeCommit message (Collapse)AuthorFilesLines
2024-02-07Add experimental support for JSON value typesBoris Kolpackov1-0/+3
New types: json json_array json_object New functions: $json.value_type(<json>) $json.value_size(<json>) $json.member_{name,value}(<json-member>) $json.object_names(<json-object>) $json.array_size(<json-array>) $json.array_find(<json-array>, <json>) $json.array_find_index(<json-array>, <json>) $json.load(<path>) $json.parse(<text>) $json.serialize(<json>[, <indentation>]) For example, to load a JSON value from a file: j = $json.load($src_base/board.json) Or to construct it in a buildfile: j = [json] one@1 two@([json] 2 3 4) three@([json] x@1 y@-1) This can also be done incrementally with append/prepend: j = [json_object] j += one@1 j += two@([json] 2 3 4) j += three@([json] x@1 y@-1) Instead of using this JSON-like syntax, one can also specify valid JSON input text: j = [json] '{"one":1, "two":[2, 3, 4], "three":{"x":1, "y":-1}' Besides the above set of functions, other handy ways to access components in a JSON value are iteration and subscript. For example: for m: $j print $member_name($m) $member_value($m) print ($j[three]) A subscript can be nested: print ($j[two][1]) print ($j[three][x]) While a JSON value can be printed directly like any other value, the representation will not be pretty-printed. As a result, for complex JSON values, printing a serialized representation might be a more readable option: info $serialize($j)
2023-11-02Add $first()/$second() pair functionsBoris Kolpackov1-0/+25
2022-09-30Move integer and bool function to separate source/testscript filesBoris Kolpackov1-39/+2
2022-09-29Add $find(<sequence>, <value>), $find_index(<sequence>, <value>) functionsBoris Kolpackov1-0/+14
The $find() function returns true if the sequence contains the specified value. The $find_index() function returns the index of the first element in the sequence that is equal to the specified value or $size(<sequence>) if none is found. For string sequences, it's possible to request case- insensitive comparison with a flag.
2022-09-22Add $integer_sequence(<begin>, <end>[, <step>]) functionBoris Kolpackov1-0/+8
It returns the list of uint64 integers starting from <begin> (including) to <end> (excluding) with the specified <step> or 1 if unspecified. For example: hdr = foo.hxx bar.hxx baz.hxx src = foo.cxx bar.cxx baz.cxx assert ($size($hdr) == $size($src)) "hdr and src expected to be parallel" for i: $integer_sequence(0, $size($hdr)) { h = ($hdr[$i]) s = ($src[$i]) ... }
2022-09-22Add support for hex notation for uint64 typeBoris Kolpackov1-0/+8
Specifically, now we can do: x = [uint64] 0x0000ffff cxx.poptions += "-DOFFSET=$x" # -DOFFSET=65535 cxx.poptions += "-DOFFSET=$string($x, 16)" # -DOFFSET=0xffff cxx.poptions += "-DOFFSET=$string($x, 16, 8)" # -DOFFSET=0x0000ffff Note that there is no hex notation support for the int64 (signed) type.
2021-11-04Add $size() function to get size of sequence (names, strings, etc)Boris Kolpackov1-5/+2
2021-11-02Add $sort() functionBoris Kolpackov1-0/+10
Available overloads: $sort(<names> [, <flags>]) $sort(<ints> [, <flags>]) $sort(<strings> [, <flags>]) $sort(<paths> [, <flags>]) $sort(<dir_paths> [, <flags>]) The following flag is supported by the all overloads: dedup - in addition to sorting also remove duplicates Additionally, the strings overload also support the following flag: icase - sort ignoring case Note that on case-insensitive filesystem the paths and dir_paths overload's order is case-insensitive.
2020-03-17Add $defined(<variable>) functionBoris Kolpackov1-2/+17
2020-02-07Drop copyright notice from source codeKaren Arutyunov2-2/+0
2019-11-15Generalize attributes to be comma-separated with arbitrary valuesBoris Kolpackov1-3/+3
Before: x = [string null] After: x = [string, null]
2019-11-05Fix testsBoris Kolpackov1-0/+1
2019-01-16Update copyright yearKaren Arutyunov2-2/+2
2018-09-04Rename .test/test{} to .testscript/testscript{}Boris Kolpackov1-1/+1
2018-07-16Resolve function overload via the argument reversal to untypedBoris Kolpackov1-10/+1
2018-05-19Update copyright yearKaren Arutyunov2-2/+2
2018-05-19Get rid of doc{version} and types for testscript and manifest in buildfilesKaren Arutyunov1-1/+1
2017-06-21Add support for $envvar() functionKaren Arutyunov1-0/+61
2017-01-23Implement automatic loading of directory buildfilesBoris Kolpackov1-1/+1
Now instead of explicitly writing: d = foo/ bar/ ./: $d include $d We can (usually) just write: ./: foo/ bar/
2017-01-05Update copyright yearBoris Kolpackov2-2/+2
2016-12-16Convert tests/ to subproject, initial work on cross-testing supportBoris Kolpackov1-1/+1
2016-12-09Initial parallel scheduler implementation, use to run testscripsBoris Kolpackov1-2/+2
2016-12-01Organize tests/, factor common testscript fragmentsBoris Kolpackov2-9/+1
2016-11-25Implement literal here-document supportBoris Kolpackov1-1/+1
2016-11-23Implement few builtin functions that can operate on any valueBoris Kolpackov2-0/+75
type() null() empty () identity()