From d5b0282c239b9c8a84bf29a92735b514cd6b7001 Mon Sep 17 00:00:00 2001 From: Glenn Sarti Date: Thu, 1 Aug 2024 14:00:36 +0800 Subject: [PATCH] Add snap tests for sentinel language --- tests/snapshot/sentinel/boolean_expr.sentinel | 43 ++ .../sentinel/boolean_expr.sentinel.snap | 398 ++++++++++++++++++ tests/snapshot/sentinel/collections.sentinel | 15 + .../sentinel/collections.sentinel.snap | 89 ++++ tests/snapshot/sentinel/comments.sentinel | 14 + .../snapshot/sentinel/comments.sentinel.snap | 28 ++ tests/snapshot/sentinel/conditional.sentinel | 41 ++ .../sentinel/conditional.sentinel.snap | 218 ++++++++++ tests/snapshot/sentinel/functions.sentinel | 37 ++ .../snapshot/sentinel/functions.sentinel.snap | 149 +++++++ tests/snapshot/sentinel/imports.sentinel | 8 + tests/snapshot/sentinel/imports.sentinel.snap | 36 ++ tests/snapshot/sentinel/lists.sentinel | 17 + tests/snapshot/sentinel/lists.sentinel.snap | 165 ++++++++ .../snapshot/sentinel/logging_errors.sentinel | 10 + .../sentinel/logging_errors.sentinel.snap | 53 +++ tests/snapshot/sentinel/loops.sentinel | 14 + tests/snapshot/sentinel/loops.sentinel.snap | 68 +++ tests/snapshot/sentinel/maps.sentinel | 43 ++ tests/snapshot/sentinel/maps.sentinel.snap | 336 +++++++++++++++ tests/snapshot/sentinel/maths.sentinel | 6 + tests/snapshot/sentinel/maths.sentinel.snap | 48 +++ tests/snapshot/sentinel/params.sentinel | 6 + tests/snapshot/sentinel/params.sentinel.snap | 25 ++ tests/snapshot/sentinel/rules.sentinel | 25 ++ tests/snapshot/sentinel/rules.sentinel.snap | 193 +++++++++ tests/snapshot/sentinel/slices.sentinel | 9 + tests/snapshot/sentinel/slices.sentinel.snap | 54 +++ tests/snapshot/sentinel/undefined.sentinel | 10 + .../snapshot/sentinel/undefined.sentinel.snap | 49 +++ tests/snapshot/sentinel/values.sentinel | 51 +++ tests/snapshot/sentinel/values.sentinel.snap | 326 ++++++++++++++ tests/snapshot/sentinel/variables.sentinel | 16 + .../snapshot/sentinel/variables.sentinel.snap | 76 ++++ 34 files changed, 2676 insertions(+) create mode 100644 tests/snapshot/sentinel/boolean_expr.sentinel create mode 100644 tests/snapshot/sentinel/boolean_expr.sentinel.snap create mode 100644 tests/snapshot/sentinel/collections.sentinel create mode 100644 tests/snapshot/sentinel/collections.sentinel.snap create mode 100644 tests/snapshot/sentinel/comments.sentinel create mode 100644 tests/snapshot/sentinel/comments.sentinel.snap create mode 100644 tests/snapshot/sentinel/conditional.sentinel create mode 100644 tests/snapshot/sentinel/conditional.sentinel.snap create mode 100644 tests/snapshot/sentinel/functions.sentinel create mode 100644 tests/snapshot/sentinel/functions.sentinel.snap create mode 100644 tests/snapshot/sentinel/imports.sentinel create mode 100644 tests/snapshot/sentinel/imports.sentinel.snap create mode 100644 tests/snapshot/sentinel/lists.sentinel create mode 100644 tests/snapshot/sentinel/lists.sentinel.snap create mode 100644 tests/snapshot/sentinel/logging_errors.sentinel create mode 100644 tests/snapshot/sentinel/logging_errors.sentinel.snap create mode 100644 tests/snapshot/sentinel/loops.sentinel create mode 100644 tests/snapshot/sentinel/loops.sentinel.snap create mode 100644 tests/snapshot/sentinel/maps.sentinel create mode 100644 tests/snapshot/sentinel/maps.sentinel.snap create mode 100644 tests/snapshot/sentinel/maths.sentinel create mode 100644 tests/snapshot/sentinel/maths.sentinel.snap create mode 100644 tests/snapshot/sentinel/params.sentinel create mode 100644 tests/snapshot/sentinel/params.sentinel.snap create mode 100644 tests/snapshot/sentinel/rules.sentinel create mode 100644 tests/snapshot/sentinel/rules.sentinel.snap create mode 100644 tests/snapshot/sentinel/slices.sentinel create mode 100644 tests/snapshot/sentinel/slices.sentinel.snap create mode 100644 tests/snapshot/sentinel/undefined.sentinel create mode 100644 tests/snapshot/sentinel/undefined.sentinel.snap create mode 100644 tests/snapshot/sentinel/values.sentinel create mode 100644 tests/snapshot/sentinel/values.sentinel.snap create mode 100644 tests/snapshot/sentinel/variables.sentinel create mode 100644 tests/snapshot/sentinel/variables.sentinel.snap diff --git a/tests/snapshot/sentinel/boolean_expr.sentinel b/tests/snapshot/sentinel/boolean_expr.sentinel new file mode 100644 index 0000000..6227c55 --- /dev/null +++ b/tests/snapshot/sentinel/boolean_expr.sentinel @@ -0,0 +1,43 @@ +# https://developer.hashicorp.com/sentinel/docs/language/boolexpr + +value = (p and q) or r +value = p and (q or r) + +value = 42 == -1 +value = 42 != -1 +value = 42 < -1 +value = 42 <= -1 +value = 42 > -1 +value = 42 >= -1 + +# Sets +value = [1, 2, 3] contains 2 +value = [1, 2, 3] contains 5 +value = [1, 2, 3] contains "value" +value = [1, 2, 3] not contains "value" + +value = { "a": 1, "b": 2 } contains "a" +value = { "a": 1, "b": 2 } contains "c" +value = { "a": 1, "b": 2 } contains 2 +value = { "a": 1, "b": 2 } not contains 2 + +# Matches +value = "test" matches "e" +value = "test" matches "^e" +value = "TEST" matches "test" +value = "TEST" matches "(?i)test" +value = "ABC123" matches "[A-Z]+\\d+" +value = "test" not matches "e" + +# Any, All +all group.tasks as t { t.driver is "vmware" } +any group.tasks as t { t.driver is "vmware" } + +any ["a", "b"] as char { char is "a" } or other_value is "another" + +# Emptiness/Defined +value = x is empty +value = x is not empty + +value = x is defined +value = x is not defined diff --git a/tests/snapshot/sentinel/boolean_expr.sentinel.snap b/tests/snapshot/sentinel/boolean_expr.sentinel.snap new file mode 100644 index 0000000..6db141e --- /dev/null +++ b/tests/snapshot/sentinel/boolean_expr.sentinel.snap @@ -0,0 +1,398 @@ +># https://developer.hashicorp.com/sentinel/docs/language/boolexpr +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.number-sign.sentinel +> +>value = (p and q) or r +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^^ source.sentinel +# ^^^ source.sentinel keyword.control.sentinel +# ^^^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^^^ source.sentinel +>value = p and (q or r) +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^ source.sentinel +# ^^^ source.sentinel keyword.control.sentinel +# ^^^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^^^^ source.sentinel +> +>value = 42 == -1 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^ source.sentinel constant.numeric.number.sentinel +# ^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +>value = 42 != -1 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^ source.sentinel constant.numeric.number.sentinel +# ^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +>value = 42 < -1 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^ source.sentinel constant.numeric.number.sentinel +# ^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +>value = 42 <= -1 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^ source.sentinel constant.numeric.number.sentinel +# ^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +>value = 42 > -1 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^ source.sentinel constant.numeric.number.sentinel +# ^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +>value = 42 >= -1 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^ source.sentinel constant.numeric.number.sentinel +# ^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +> +># Sets +#^^^^^^ source.sentinel comment.line.number-sign.sentinel +>value = [1, 2, 3] contains 2 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^^^^^^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +>value = [1, 2, 3] contains 5 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^^^^^^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +>value = [1, 2, 3] contains "value" +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^^^^^^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +>value = [1, 2, 3] not contains "value" +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^^^^^^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +> +>value = { "a": 1, "b": 2 } contains "a" +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^^ source.sentinel +# ^^^^^^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +>value = { "a": 1, "b": 2 } contains "c" +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^^ source.sentinel +# ^^^^^^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +>value = { "a": 1, "b": 2 } contains 2 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^^ source.sentinel +# ^^^^^^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +>value = { "a": 1, "b": 2 } not contains 2 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^^ source.sentinel +# ^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^^^^^^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +> +># Matches +#^^^^^^^^^ source.sentinel comment.line.number-sign.sentinel +>value = "test" matches "e" +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel +# ^^^^^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +>value = "test" matches "^e" +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel +# ^^^^^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +>value = "TEST" matches "test" +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel +# ^^^^^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +>value = "TEST" matches "(?i)test" +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel +# ^^^^^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +>value = "ABC123" matches "[A-Z]+\\d+" +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel +# ^^^^^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel string.quoted.double.untitled constant.character.escape.single.sentinel +# ^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +>value = "test" not matches "e" +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel +# ^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^^^^^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +> +># Any, All +#^^^^^^^^^^ source.sentinel comment.line.number-sign.sentinel +>all group.tasks as t { t.driver is "vmware" } +#^^^ source.sentinel keyword.control.sentinel +# ^^^^^^^^^^^^^ source.sentinel +# ^^ source.sentinel keyword.other.sentinel +# ^^^^^^^^^^^^^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel +>any group.tasks as t { t.driver is "vmware" } +#^^^ source.sentinel keyword.control.sentinel +# ^^^^^^^^^^^^^ source.sentinel +# ^^ source.sentinel keyword.other.sentinel +# ^^^^^^^^^^^^^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel +> +>any ["a", "b"] as char { char is "a" } or other_value is "another" +#^^^ source.sentinel keyword.control.sentinel +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^^ source.sentinel keyword.other.sentinel +# ^^^^^^^^^^^^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^^^^^^^^^^^^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +> +># Emptiness/Defined +#^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.number-sign.sentinel +>value = x is empty +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^^^^^^^ source.sentinel +>value = x is not empty +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^^^ source.sentinel keyword.control.sentinel +# ^^^^^^^ source.sentinel +> +>value = x is defined +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^^^^^^^^^ source.sentinel +>value = x is not defined +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^^^ source.sentinel keyword.control.sentinel +# ^^^^^^^^^ source.sentinel +> \ No newline at end of file diff --git a/tests/snapshot/sentinel/collections.sentinel b/tests/snapshot/sentinel/collections.sentinel new file mode 100644 index 0000000..c8d269d --- /dev/null +++ b/tests/snapshot/sentinel/collections.sentinel @@ -0,0 +1,15 @@ +# https://developer.hashicorp.com/sentinel/docs/language/collection-operations + +# filter +filter list as value { condition } // Single-iterator, list +filter list as idx, value { condition } // Double-iterator, list + +filter map as key { condition } // Single-iterator, map +filter map as key, value { condition } // Double-iterator, map + +# map +l = [1, 2] +r = map l as v { v % 2 } // [false, true] + +m = { "a": "foo", "b": "bar" } +r = map m as k, v { v } // ["foo", "bar"] diff --git a/tests/snapshot/sentinel/collections.sentinel.snap b/tests/snapshot/sentinel/collections.sentinel.snap new file mode 100644 index 0000000..72c81e7 --- /dev/null +++ b/tests/snapshot/sentinel/collections.sentinel.snap @@ -0,0 +1,89 @@ +># https://developer.hashicorp.com/sentinel/docs/language/collection-operations +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.number-sign.sentinel +> +># filter +#^^^^^^^^ source.sentinel comment.line.number-sign.sentinel +>filter list as value { condition } // Single-iterator, list +#^^^^^^ source.sentinel keyword.control.sentinel +# ^^^^^^ source.sentinel +# ^^ source.sentinel keyword.other.sentinel +# ^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel +# ^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>filter list as idx, value { condition } // Double-iterator, list +#^^^^^^ source.sentinel keyword.control.sentinel +# ^^^^^^ source.sentinel +# ^^ source.sentinel keyword.other.sentinel +# ^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel +# ^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +> +>filter map as key { condition } // Single-iterator, map +#^^^^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^^ source.sentinel keyword.other.sentinel +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel +# ^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>filter map as key, value { condition } // Double-iterator, map +#^^^^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^^ source.sentinel keyword.other.sentinel +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel +# ^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +> +># map +#^^^^^ source.sentinel comment.line.number-sign.sentinel +>l = [1, 2] +#^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +>r = map l as v { v % 2 } // [false, true] +#^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^ source.sentinel keyword.control.sentinel +# ^^^ source.sentinel +# ^^ source.sentinel keyword.other.sentinel +# ^^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^^ source.sentinel +# ^^^^^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +> +>m = { "a": "foo", "b": "bar" } +#^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel +>r = map m as k, v { v } // ["foo", "bar"] +#^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^ source.sentinel keyword.control.sentinel +# ^^^ source.sentinel +# ^^ source.sentinel keyword.other.sentinel +# ^^^^^^^^^^^^ source.sentinel +# ^^^^^^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +> \ No newline at end of file diff --git a/tests/snapshot/sentinel/comments.sentinel b/tests/snapshot/sentinel/comments.sentinel new file mode 100644 index 0000000..e13760f --- /dev/null +++ b/tests/snapshot/sentinel/comments.sentinel @@ -0,0 +1,14 @@ +# https://developer.hashicorp.com/sentinel/docs/language/spec#comments + +# Single line comment +comment + +comment # Single line comment + +// Single line comment +comment + +/* multi +line + comment */ +comment diff --git a/tests/snapshot/sentinel/comments.sentinel.snap b/tests/snapshot/sentinel/comments.sentinel.snap new file mode 100644 index 0000000..475946c --- /dev/null +++ b/tests/snapshot/sentinel/comments.sentinel.snap @@ -0,0 +1,28 @@ +># https://developer.hashicorp.com/sentinel/docs/language/spec#comments +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.number-sign.sentinel +> +># Single line comment +#^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.number-sign.sentinel +>comment +#^^^^^^^^ source.sentinel +> +>comment # Single line comment +#^^^^^^^^ source.sentinel +# ^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.number-sign.sentinel +> +>// Single line comment +#^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>comment +#^^^^^^^^ source.sentinel +> +>/* multi +#^^ source.sentinel comment.line.block.sentinel +# ^^^^^^^ source.sentinel comment.line.block.sentinel +>line +#^^^^^ source.sentinel comment.line.block.sentinel +> comment */ +#^^^^^^^^^^^^ source.sentinel comment.line.block.sentinel +# ^^ source.sentinel comment.line.block.sentinel +>comment +#^^^^^^^^ source.sentinel +> \ No newline at end of file diff --git a/tests/snapshot/sentinel/conditional.sentinel b/tests/snapshot/sentinel/conditional.sentinel new file mode 100644 index 0000000..d6d4fff --- /dev/null +++ b/tests/snapshot/sentinel/conditional.sentinel @@ -0,0 +1,41 @@ +# https://developer.hashicorp.com/sentinel/docs/language/conditionals + +# Single line if statements +if value is 18 { print("condition met") } +if value { print("condition met") } +if value["key"] > 12 { print("condition met") } + +# Multi-line if statements +if value is 18 { + print("condition met") +} + +if value { + print("condition met") +} + +if value["key"] > 12 { + print("condition met") +} + +# Multi-line if-elseif-else statements +if value is 18 { print("condition met") } else if value { print("condition met") } else { print("condition met") } + +# Multi-line if-elseif-else statements +if value is 18 { + print("condition met") +} else if value { + print("condition met") +} else { + print("condition met") +} + +// Case statements +case x { when "foo", "bar": return true; else: return false } + +case x { + when "foo", "bar": + return true + else: + return false +} diff --git a/tests/snapshot/sentinel/conditional.sentinel.snap b/tests/snapshot/sentinel/conditional.sentinel.snap new file mode 100644 index 0000000..ff956c5 --- /dev/null +++ b/tests/snapshot/sentinel/conditional.sentinel.snap @@ -0,0 +1,218 @@ +># https://developer.hashicorp.com/sentinel/docs/language/conditionals +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.number-sign.sentinel +> +># Single line if statements +#^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.number-sign.sentinel +>if value is 18 { print("condition met") } +#^^ source.sentinel keyword.control.sentinel +# ^^^^^^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^^ source.sentinel constant.numeric.number.sentinel +# ^^^ source.sentinel +# ^^^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^^^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^^ source.sentinel +>if value { print("condition met") } +#^^ source.sentinel keyword.control.sentinel +# ^^^^^^^^^ source.sentinel +# ^^^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^^^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^^ source.sentinel +>if value["key"] > 12 { print("condition met") } +#^^ source.sentinel keyword.control.sentinel +# ^^^^^^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^ source.sentinel constant.numeric.number.sentinel +# ^^^ source.sentinel +# ^^^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^^^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^^ source.sentinel +> +># Multi-line if statements +#^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.number-sign.sentinel +>if value is 18 { +#^^ source.sentinel keyword.control.sentinel +# ^^^^^^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^^ source.sentinel constant.numeric.number.sentinel +# ^^^ source.sentinel +> print("condition met") +#^ source.sentinel +# ^^^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^^^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +>} +#^^ source.sentinel +> +>if value { +#^^ source.sentinel keyword.control.sentinel +# ^^^^^^^^^ source.sentinel +> print("condition met") +#^ source.sentinel +# ^^^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^^^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +>} +#^^ source.sentinel +> +>if value["key"] > 12 { +#^^ source.sentinel keyword.control.sentinel +# ^^^^^^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^ source.sentinel constant.numeric.number.sentinel +# ^^^ source.sentinel +> print("condition met") +#^ source.sentinel +# ^^^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^^^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +>} +#^^ source.sentinel +> +># Multi-line if-elseif-else statements +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.number-sign.sentinel +>if value is 18 { print("condition met") } else if value { print("condition met") } else { print("condition met") } +#^^ source.sentinel keyword.control.sentinel +# ^^^^^^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^^ source.sentinel constant.numeric.number.sentinel +# ^^^ source.sentinel +# ^^^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^^^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^^ source.sentinel +# ^^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^^^^^^^^^ source.sentinel +# ^^^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^^^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^^ source.sentinel +# ^^^^ source.sentinel keyword.control.sentinel +# ^^^ source.sentinel +# ^^^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^^^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^^ source.sentinel +> +># Multi-line if-elseif-else statements +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.number-sign.sentinel +>if value is 18 { +#^^ source.sentinel keyword.control.sentinel +# ^^^^^^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^^ source.sentinel constant.numeric.number.sentinel +# ^^^ source.sentinel +> print("condition met") +#^ source.sentinel +# ^^^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^^^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +>} else if value { +#^^ source.sentinel +# ^^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^^^^^^^^^ source.sentinel +> print("condition met") +#^ source.sentinel +# ^^^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^^^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +>} else { +#^^ source.sentinel +# ^^^^ source.sentinel keyword.control.sentinel +# ^^^ source.sentinel +> print("condition met") +#^ source.sentinel +# ^^^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^^^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +>} +#^^ source.sentinel +> +>// Case statements +#^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>case x { when "foo", "bar": return true; else: return false } +#^^^^ source.sentinel keyword.control.sentinel +# ^^^^^ source.sentinel +# ^^^^ source.sentinel keyword.control.when.sentinel +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel +# ^ source.sentinel +# ^^^^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^^^^^ source.sentinel constant.language.sentinel +# ^^^ source.sentinel +> +>case x { +#^^^^ source.sentinel keyword.control.sentinel +# ^^^^^ source.sentinel +> when "foo", "bar": +#^ source.sentinel +# ^^^^ source.sentinel keyword.control.when.sentinel +# ^^^^^^^^^^^^^^ source.sentinel +> return true +#^^ source.sentinel +# ^^^^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^^^^ source.sentinel constant.language.sentinel +> else: +#^ source.sentinel +# ^^^^ source.sentinel keyword.control.else.sentinel +# ^ source.sentinel +> return false +#^^ source.sentinel +# ^^^^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^^^^^ source.sentinel constant.language.sentinel +>} +#^^ source.sentinel +> \ No newline at end of file diff --git a/tests/snapshot/sentinel/functions.sentinel b/tests/snapshot/sentinel/functions.sentinel new file mode 100644 index 0000000..32bee07 --- /dev/null +++ b/tests/snapshot/sentinel/functions.sentinel @@ -0,0 +1,37 @@ +# https://developer.hashicorp.com/sentinel/docs/language/functions + +func sum(a, b) { + return a + b +} + +func makeAdder(a) { + return func(b) { + return a + b + } +} + +add1 = func(x) { return x + 1 } + +add2 = func add1(x) { + return x + 1 +} + +f = func() { + a = 42 + print(a) // 42 + return undefined +} + +print(a) // undefined + +fib = func(x) { + if x <= 0 { + return undefined + } + + if x == 1 { + return 1 + } else { + return x + fib(x - 1) + } +} diff --git a/tests/snapshot/sentinel/functions.sentinel.snap b/tests/snapshot/sentinel/functions.sentinel.snap new file mode 100644 index 0000000..3efb0c7 --- /dev/null +++ b/tests/snapshot/sentinel/functions.sentinel.snap @@ -0,0 +1,149 @@ +># https://developer.hashicorp.com/sentinel/docs/language/functions +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.number-sign.sentinel +> +>func sum(a, b) { +#^^^^ source.sentinel keyword.other.sentinel +# ^^^^^^^^^^^^^ source.sentinel +> return a + b +#^^ source.sentinel +# ^^^^^^ source.sentinel keyword.control.sentinel +# ^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^ source.sentinel +>} +#^^ source.sentinel +> +>func makeAdder(a) { +#^^^^ source.sentinel keyword.other.sentinel +# ^^^^^^^^^^^^^^^^ source.sentinel +> return func(b) { +#^^ source.sentinel +# ^^^^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^^^^ source.sentinel keyword.other.sentinel +# ^^^^^^ source.sentinel +> return a + b +#^^^^ source.sentinel +# ^^^^^^ source.sentinel keyword.control.sentinel +# ^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^ source.sentinel +> } +#^^^^ source.sentinel +>} +#^^ source.sentinel +> +>add1 = func(x) { return x + 1 } +#^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^ source.sentinel keyword.other.sentinel +# ^^^^^^ source.sentinel +# ^^^^^^ source.sentinel keyword.control.sentinel +# ^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^^ source.sentinel +> +>add2 = func add1(x) { +#^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^ source.sentinel keyword.other.sentinel +# ^^^^^^^^^^^ source.sentinel +> return x + 1 +#^^ source.sentinel +# ^^^^^^ source.sentinel keyword.control.sentinel +# ^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +>} +#^^ source.sentinel +> +>f = func() { +#^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^ source.sentinel keyword.other.sentinel +# ^^^^^ source.sentinel +> a = 42 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^ source.sentinel constant.numeric.number.sentinel +> print(a) // 42 +#^^^^ source.sentinel +# ^^^^^ source.sentinel support.function.builtin.sentinel +# ^^^^ source.sentinel +# ^^^^^ source.sentinel comment.line.double-slash.sentinel +> return undefined +#^^^^ source.sentinel +# ^^^^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^^^^^^^^^ source.sentinel constant.language.sentinel +>} +#^^ source.sentinel +> +>print(a) // undefined +#^^^^^ source.sentinel support.function.builtin.sentinel +# ^^^^ source.sentinel +# ^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +> +>fib = func(x) { +#^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^ source.sentinel keyword.other.sentinel +# ^^^^^^ source.sentinel +> if x <= 0 { +#^^^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^^ source.sentinel +> return undefined +#^^^^^^^^ source.sentinel +# ^^^^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^^^^^^^^^ source.sentinel constant.language.sentinel +> } +#^^^^^^ source.sentinel +> +> if x == 1 { +#^^^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^^ source.sentinel +> return 1 +#^^^^^^^^ source.sentinel +# ^^^^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +> } else { +#^^^^^^ source.sentinel +# ^^^^ source.sentinel keyword.control.sentinel +# ^^^ source.sentinel +> return x + fib(x - 1) +#^^^^^^^^ source.sentinel +# ^^^^^^ source.sentinel keyword.control.sentinel +# ^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +> } +#^^^^^^ source.sentinel +>} +#^^ source.sentinel +> \ No newline at end of file diff --git a/tests/snapshot/sentinel/imports.sentinel b/tests/snapshot/sentinel/imports.sentinel new file mode 100644 index 0000000..8237f03 --- /dev/null +++ b/tests/snapshot/sentinel/imports.sentinel @@ -0,0 +1,8 @@ +# https://developer.hashicorp.com/sentinel/docs/language/imports + +import "calendar" + +import "name" + +import "name1" as one +import "name2" as two diff --git a/tests/snapshot/sentinel/imports.sentinel.snap b/tests/snapshot/sentinel/imports.sentinel.snap new file mode 100644 index 0000000..11d2fae --- /dev/null +++ b/tests/snapshot/sentinel/imports.sentinel.snap @@ -0,0 +1,36 @@ +># https://developer.hashicorp.com/sentinel/docs/language/imports +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.number-sign.sentinel +> +>import "calendar" +#^^^^^^ source.sentinel keyword.control.declaration.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +> +>import "name" +#^^^^^^ source.sentinel keyword.control.declaration.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +> +>import "name1" as one +#^^^^^^ source.sentinel keyword.control.declaration.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel +# ^^ source.sentinel keyword.other.sentinel +# ^^^^^ source.sentinel +>import "name2" as two +#^^^^^^ source.sentinel keyword.control.declaration.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel +# ^^ source.sentinel keyword.other.sentinel +# ^^^^^ source.sentinel +> \ No newline at end of file diff --git a/tests/snapshot/sentinel/lists.sentinel b/tests/snapshot/sentinel/lists.sentinel new file mode 100644 index 0000000..99be567 --- /dev/null +++ b/tests/snapshot/sentinel/lists.sentinel @@ -0,0 +1,17 @@ +# https://developer.hashicorp.com/sentinel/docs/language/lists + +[] // An empty list +["foo"] // Single element list +["foo", 1, 2, true] // Multi element list with different types +["foo", [1, 2]] // List containing another list + + +value = append([1,2], 3) // [1, 2, 3] +value = append([1,2], "foo") // [1, 2, "foo"] +value = append([1,2], [3]) // [1, 2, [3]] +value = append(1, 3) // error() + +[1, 2] is [1, 2] // true +[1, 2] is [2, 1] // false +["a"] is ["a", "b"] // false +["a", ["b", "c"]] is ["a", ["b", "c"]] // true diff --git a/tests/snapshot/sentinel/lists.sentinel.snap b/tests/snapshot/sentinel/lists.sentinel.snap new file mode 100644 index 0000000..91c74af --- /dev/null +++ b/tests/snapshot/sentinel/lists.sentinel.snap @@ -0,0 +1,165 @@ +># https://developer.hashicorp.com/sentinel/docs/language/lists +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.number-sign.sentinel +> +>[] // An empty list +#^^^^^^^^^^^^^^^^^^^^ source.sentinel +# ^^^^^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>["foo"] // Single element list +#^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^^^^^^^^ source.sentinel +# ^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>["foo", 1, 2, true] // Multi element list with different types +#^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^^^^ source.sentinel constant.language.sentinel +# ^^ source.sentinel +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>["foo", [1, 2]] // List containing another list +#^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^^^^^^ source.sentinel +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +> +> +>value = append([1,2], 3) // [1, 2, 3] +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^^^ source.sentinel support.function.builtin.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^^^^^^ source.sentinel +# ^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>value = append([1,2], "foo") // [1, 2, "foo"] +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^^^ source.sentinel support.function.builtin.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel +# ^^^^^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>value = append([1,2], [3]) // [1, 2, [3]] +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^^^ source.sentinel support.function.builtin.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^^^^^ source.sentinel +# ^^^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>value = append(1, 3) // error() +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^^^^^^^^^^ source.sentinel +# ^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +> +>[1, 2] is [1, 2] // true +#^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel +# ^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>[1, 2] is [2, 1] // false +#^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel +# ^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>["a"] is ["a", "b"] // false +#^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^^^^^^^^^^^^^^^ source.sentinel +# ^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>["a", ["b", "c"]] is ["a", ["b", "c"]] // true +#^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel +# ^^^^^^^ source.sentinel comment.line.double-slash.sentinel +> \ No newline at end of file diff --git a/tests/snapshot/sentinel/logging_errors.sentinel b/tests/snapshot/sentinel/logging_errors.sentinel new file mode 100644 index 0000000..ec1d93e --- /dev/null +++ b/tests/snapshot/sentinel/logging_errors.sentinel @@ -0,0 +1,10 @@ +# https://developer.hashicorp.com/sentinel/docs/language/logging-errors + +value = 42 +print("the value is", value) // the value is 42 + +map = { "foo": false } +print(map) // { "foo": false } + +one_is_zero = rule { 1 == 0 } +print(one_is_zero) // false diff --git a/tests/snapshot/sentinel/logging_errors.sentinel.snap b/tests/snapshot/sentinel/logging_errors.sentinel.snap new file mode 100644 index 0000000..5286e0a --- /dev/null +++ b/tests/snapshot/sentinel/logging_errors.sentinel.snap @@ -0,0 +1,53 @@ +># https://developer.hashicorp.com/sentinel/docs/language/logging-errors +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.number-sign.sentinel +> +>value = 42 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^ source.sentinel constant.numeric.number.sentinel +>print("the value is", value) // the value is 42 +#^^^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^^^ source.sentinel +# ^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +> +>map = { "foo": false } +#^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^^^^^ source.sentinel constant.language.sentinel +# ^^^ source.sentinel +>print(map) // { "foo": false } +#^^^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^^^ source.sentinel keyword.control.sentinel +# ^^ source.sentinel +# ^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +> +>one_is_zero = rule { 1 == 0 } +#^^^^^^^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^ source.sentinel keyword.other.sentinel +# ^^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^^ source.sentinel +>print(one_is_zero) // false +#^^^^^ source.sentinel support.function.builtin.sentinel +# ^^^^^^^^^^^^^^ source.sentinel +# ^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +> \ No newline at end of file diff --git a/tests/snapshot/sentinel/loops.sentinel b/tests/snapshot/sentinel/loops.sentinel new file mode 100644 index 0000000..db96726 --- /dev/null +++ b/tests/snapshot/sentinel/loops.sentinel @@ -0,0 +1,14 @@ +# https://developer.hashicorp.com/sentinel/docs/language/loops + +for { "a": 1, "b": 2 } as name { + append(list, name) +} + +for list as value { + a = 42 +} +for list as value { a = 42 } + +for [1, 2, 3] as num { + count += num +} diff --git a/tests/snapshot/sentinel/loops.sentinel.snap b/tests/snapshot/sentinel/loops.sentinel.snap new file mode 100644 index 0000000..bcd2f5f --- /dev/null +++ b/tests/snapshot/sentinel/loops.sentinel.snap @@ -0,0 +1,68 @@ +># https://developer.hashicorp.com/sentinel/docs/language/loops +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.number-sign.sentinel +> +>for { "a": 1, "b": 2 } as name { +#^^^ source.sentinel keyword.control.sentinel +# ^^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^^ source.sentinel +# ^^ source.sentinel keyword.other.sentinel +# ^^^^^^^^ source.sentinel +> append(list, name) +#^^^^ source.sentinel +# ^^^^^^ source.sentinel support.function.builtin.sentinel +# ^^^^^^^^^^^^^ source.sentinel +>} +#^^ source.sentinel +> +>for list as value { +#^^^ source.sentinel keyword.control.sentinel +# ^^^^^^ source.sentinel +# ^^ source.sentinel keyword.other.sentinel +# ^^^^^^^^^ source.sentinel +> a = 42 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^ source.sentinel constant.numeric.number.sentinel +>} +#^^ source.sentinel +>for list as value { a = 42 } +#^^^ source.sentinel keyword.control.sentinel +# ^^^^^^ source.sentinel +# ^^ source.sentinel keyword.other.sentinel +# ^^^^^^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^ source.sentinel constant.numeric.number.sentinel +# ^^^ source.sentinel +> +>for [1, 2, 3] as num { +#^^^ source.sentinel keyword.control.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^^ source.sentinel keyword.other.sentinel +# ^^^^^^^ source.sentinel +> count += num +#^^^^^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^^^ source.sentinel +>} +#^^ source.sentinel +> \ No newline at end of file diff --git a/tests/snapshot/sentinel/maps.sentinel b/tests/snapshot/sentinel/maps.sentinel new file mode 100644 index 0000000..d772389 --- /dev/null +++ b/tests/snapshot/sentinel/maps.sentinel @@ -0,0 +1,43 @@ +# https://developer.hashicorp.com/sentinel/docs/language/maps + +// Empty map +{} + +// Map with a single value on one line +{ "key": "value" } + +// Map with multiple values with differing types on multiple lines +{ + "key": "value", + 42: true, +} + +map = { "key": "value", 42: true, } + +foo["key"] // "value" +foo[42] // true +map[0] // undefined + +map = { "key": "value" } + +map[42] = true // Add a new key/value +map["key"] = 12 // Modify the value of "key" + + +map = { "key": "value" } +delete(map, "key") // map is now empty +delete(map, "other") // no effect for non-existent key + + +data = { "a": 2, "b": 3 } +keys(data) // ["b", "a"] +values(data) // [2, 3] + +{"foo": "bar"} is {"foo": "bar"} // true +{"foo": "bar"} is {"baz": "bar"} // false +{"foo": "bar"} is {"foo": "baz"} // false +{"foo": "bar"} is {"foo": "bar", "baz": "qux"} // false +{1: "a"} is {1.0: "a"} // true (int/float comparable) + +// also true (maps are not ordered): +{"m": {"a": "b"}, "l": ["a"]} is {"l": ["a"], "m": {"a": " b"}} diff --git a/tests/snapshot/sentinel/maps.sentinel.snap b/tests/snapshot/sentinel/maps.sentinel.snap new file mode 100644 index 0000000..8f0910b --- /dev/null +++ b/tests/snapshot/sentinel/maps.sentinel.snap @@ -0,0 +1,336 @@ +># https://developer.hashicorp.com/sentinel/docs/language/maps +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.number-sign.sentinel +> +>// Empty map +#^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>{} +#^^^ source.sentinel +> +>// Map with a single value on one line +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>{ "key": "value" } +#^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel +> +>// Map with multiple values with differing types on multiple lines +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>{ +#^^ source.sentinel +> "key": "value", +#^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +> 42: true, +#^^ source.sentinel +# ^^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^^^^ source.sentinel constant.language.sentinel +# ^^ source.sentinel +>} +#^^ source.sentinel +> +>map = { "key": "value", 42: true, } +#^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^^^^ source.sentinel constant.language.sentinel +# ^^^^ source.sentinel +> +>foo["key"] // "value" +#^^^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>foo[42] // true +#^^^^ source.sentinel +# ^^ source.sentinel constant.numeric.number.sentinel +# ^^^^^ source.sentinel +# ^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>map[0] // undefined +#^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^^^^^ source.sentinel +# ^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +> +>map = { "key": "value" } +#^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel +> +>map[42] = true // Add a new key/value +#^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^ source.sentinel constant.language.sentinel +# ^^^ source.sentinel +# ^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>map["key"] = 12 // Modify the value of "key" +#^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +> +> +>map = { "key": "value" } +#^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel +>delete(map, "key") // map is now empty +#^^^^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^^^ source.sentinel keyword.control.sentinel +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^ source.sentinel +# ^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>delete(map, "other") // no effect for non-existent key +#^^^^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^^^ source.sentinel keyword.control.sentinel +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +> +> +>data = { "a": 2, "b": 3 } +#^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^^ source.sentinel +>keys(data) // ["b", "a"] +#^^^^ source.sentinel support.function.builtin.sentinel +# ^^^^^^^^^^^^^ source.sentinel +# ^^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>values(data) // [2, 3] +#^^^^^^ source.sentinel support.function.builtin.sentinel +# ^^^^^^^^^^^ source.sentinel +# ^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +> +>{"foo": "bar"} is {"foo": "bar"} // true +#^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^^^^^^^^^^ source.sentinel +# ^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>{"foo": "bar"} is {"baz": "bar"} // false +#^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^^^^^^^^^^ source.sentinel +# ^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>{"foo": "bar"} is {"foo": "baz"} // false +#^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^^^^^^^^^^ source.sentinel +# ^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>{"foo": "bar"} is {"foo": "bar", "baz": "qux"} // false +#^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>{1: "a"} is {1.0: "a"} // true (int/float comparable) +#^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^^ source.sentinel +# ^^^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +> +>// also true (maps are not ordered): +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>{"m": {"a": "b"}, "l": ["a"]} is {"l": ["a"], "m": {"a": " b"}} +#^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel +> \ No newline at end of file diff --git a/tests/snapshot/sentinel/maths.sentinel b/tests/snapshot/sentinel/maths.sentinel new file mode 100644 index 0000000..97ce7c2 --- /dev/null +++ b/tests/snapshot/sentinel/maths.sentinel @@ -0,0 +1,6 @@ +# https://developer.hashicorp.com/sentinel/docs/language/arithmetic +value = 4 + 8 +value = 8 * 2 +value = 8 / 4 +value = 8 / 5 +value = 8 % 5 diff --git a/tests/snapshot/sentinel/maths.sentinel.snap b/tests/snapshot/sentinel/maths.sentinel.snap new file mode 100644 index 0000000..dff4b49 --- /dev/null +++ b/tests/snapshot/sentinel/maths.sentinel.snap @@ -0,0 +1,48 @@ +># https://developer.hashicorp.com/sentinel/docs/language/arithmetic +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.number-sign.sentinel +>value = 4 + 8 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +>value = 8 * 2 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +>value = 8 / 4 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +>value = 8 / 5 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +>value = 8 % 5 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +> \ No newline at end of file diff --git a/tests/snapshot/sentinel/params.sentinel b/tests/snapshot/sentinel/params.sentinel new file mode 100644 index 0000000..5e31c6b --- /dev/null +++ b/tests/snapshot/sentinel/params.sentinel @@ -0,0 +1,6 @@ +# https://developer.hashicorp.com/sentinel/docs/language/parameters + +param foo +param bar default 42 + +param someting default [1,2,3] diff --git a/tests/snapshot/sentinel/params.sentinel.snap b/tests/snapshot/sentinel/params.sentinel.snap new file mode 100644 index 0000000..5071114 --- /dev/null +++ b/tests/snapshot/sentinel/params.sentinel.snap @@ -0,0 +1,25 @@ +># https://developer.hashicorp.com/sentinel/docs/language/parameters +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.number-sign.sentinel +> +>param foo +#^^^^^ source.sentinel keyword.control.declaration.sentinel +# ^^^^^ source.sentinel +>param bar default 42 +#^^^^^ source.sentinel keyword.control.declaration.sentinel +# ^^^^^ source.sentinel +# ^^^^^^^ source.sentinel keyword.other.sentinel +# ^ source.sentinel +# ^^ source.sentinel constant.numeric.number.sentinel +> +>param someting default [1,2,3] +#^^^^^ source.sentinel keyword.control.declaration.sentinel +# ^^^^^^^^^^ source.sentinel +# ^^^^^^^ source.sentinel keyword.other.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +> \ No newline at end of file diff --git a/tests/snapshot/sentinel/rules.sentinel b/tests/snapshot/sentinel/rules.sentinel new file mode 100644 index 0000000..582eb4b --- /dev/null +++ b/tests/snapshot/sentinel/rules.sentinel @@ -0,0 +1,25 @@ +# https://developer.hashicorp.com/sentinel/docs/language/rules + +main = rule { + ((day is "saturday" or day is "sunday") and homework is "") or + (day in ["monday", "tuesday", "wednesday", "thursday", "friday"] and + not school_today and homework is "") +} + +is_weekend = rule { day in ["saturday", "sunday"] } + +is_valid_weekend = rule { is_weekend and homework is "" } +is_valid_weekday = rule { not is_weekend and not school_today and homework is "" } + +main = rule { is_valid_weekend or is_valid_weekday } + +example_no_when = rule { (is_prefix and is_numeric) or not is_prefix } + +example_when = rule when is_prefix { is_numeric } + +main = rule { + filter days as d { + d.day not in ["saturday", "sunday"] and + d.homework is not "" + } +} diff --git a/tests/snapshot/sentinel/rules.sentinel.snap b/tests/snapshot/sentinel/rules.sentinel.snap new file mode 100644 index 0000000..36f1495 --- /dev/null +++ b/tests/snapshot/sentinel/rules.sentinel.snap @@ -0,0 +1,193 @@ +># https://developer.hashicorp.com/sentinel/docs/language/rules +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.number-sign.sentinel +> +>main = rule { +#^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^ source.sentinel keyword.other.sentinel +# ^^^ source.sentinel +> ((day is "saturday" or day is "sunday") and homework is "") or +#^^^^^^^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^^^^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^^^ source.sentinel keyword.control.sentinel +# ^^^^^^^^^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +> (day in ["monday", "tuesday", "wednesday", "thursday", "friday"] and +#^^^^^^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^^^ source.sentinel keyword.control.sentinel +> not school_today and homework is "") +#^^ source.sentinel +# ^^^ source.sentinel keyword.control.sentinel +# ^^^^^^^^^^^^^^ source.sentinel +# ^^^ source.sentinel keyword.control.sentinel +# ^^^^^^^^^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +>} +#^^ source.sentinel +> +>is_weekend = rule { day in ["saturday", "sunday"] } +#^^^^^^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^ source.sentinel keyword.other.sentinel +# ^^^^^^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^^ source.sentinel +> +>is_valid_weekend = rule { is_weekend and homework is "" } +#^^^^^^^^^^^^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^ source.sentinel keyword.other.sentinel +# ^^^^^^^^^^^^^^ source.sentinel +# ^^^ source.sentinel keyword.control.sentinel +# ^^^^^^^^^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel +>is_valid_weekday = rule { not is_weekend and not school_today and homework is "" } +#^^^^^^^^^^^^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^ source.sentinel keyword.other.sentinel +# ^^^ source.sentinel +# ^^^ source.sentinel keyword.control.sentinel +# ^^^^^^^^^^^^ source.sentinel +# ^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^^^ source.sentinel keyword.control.sentinel +# ^^^^^^^^^^^^^^ source.sentinel +# ^^^ source.sentinel keyword.control.sentinel +# ^^^^^^^^^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel +> +>main = rule { is_valid_weekend or is_valid_weekday } +#^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^ source.sentinel keyword.other.sentinel +# ^^^^^^^^^^^^^^^^^^^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^^^^^^^^^^^^^^^^^^^^ source.sentinel +> +>example_no_when = rule { (is_prefix and is_numeric) or not is_prefix } +#^^^^^^^^^^^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^ source.sentinel keyword.other.sentinel +# ^^^^^^^^^^^^^^ source.sentinel +# ^^^ source.sentinel keyword.control.sentinel +# ^^^^^^^^^^^^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^^^ source.sentinel keyword.control.sentinel +# ^^^^^^^^^^^^^ source.sentinel +> +>example_when = rule when is_prefix { is_numeric } +#^^^^^^^^^^^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^ source.sentinel keyword.other.sentinel +# ^ source.sentinel +# ^^^^ source.sentinel keyword.other.sentinel +# ^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel +> +>main = rule { +#^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^ source.sentinel keyword.other.sentinel +# ^^^ source.sentinel +> filter days as d { +#^^ source.sentinel +# ^^^^^^ source.sentinel keyword.control.sentinel +# ^^^^^^ source.sentinel +# ^^ source.sentinel keyword.other.sentinel +# ^^^^^ source.sentinel +> d.day not in ["saturday", "sunday"] and +#^^^^^^^^^^ source.sentinel +# ^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^^^ source.sentinel keyword.control.sentinel +> d.homework is not "" +#^^^^^^^^^^^^^^^^^ source.sentinel +# ^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +> } +#^^^^ source.sentinel +>} +#^^ source.sentinel +> \ No newline at end of file diff --git a/tests/snapshot/sentinel/slices.sentinel b/tests/snapshot/sentinel/slices.sentinel new file mode 100644 index 0000000..e95d4db --- /dev/null +++ b/tests/snapshot/sentinel/slices.sentinel @@ -0,0 +1,9 @@ +# https://developer.hashicorp.com/sentinel/docs/language/slices +a = [1, 2, 3, 4, 5] +b = a[1:4] + +a = "hello" +b = a[1:4] + +b = a[:2] +b = a[2:] diff --git a/tests/snapshot/sentinel/slices.sentinel.snap b/tests/snapshot/sentinel/slices.sentinel.snap new file mode 100644 index 0000000..1153860 --- /dev/null +++ b/tests/snapshot/sentinel/slices.sentinel.snap @@ -0,0 +1,54 @@ +># https://developer.hashicorp.com/sentinel/docs/language/slices +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.number-sign.sentinel +>a = [1, 2, 3, 4, 5] +#^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +>b = a[1:4] +#^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +> +>a = "hello" +#^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +>b = a[1:4] +#^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +> +>b = a[:2] +#^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +>b = a[2:] +#^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^^ source.sentinel +> \ No newline at end of file diff --git a/tests/snapshot/sentinel/undefined.sentinel b/tests/snapshot/sentinel/undefined.sentinel new file mode 100644 index 0000000..a0bb076 --- /dev/null +++ b/tests/snapshot/sentinel/undefined.sentinel @@ -0,0 +1,10 @@ +# https://developer.hashicorp.com/sentinel/docs/language/undefined + +foo() else 42 +foo.bar else "" +config["bad-key"] else "default" + +// In more complex scenarios + +foo() else 42 == 12 +a = config.value else "default" diff --git a/tests/snapshot/sentinel/undefined.sentinel.snap b/tests/snapshot/sentinel/undefined.sentinel.snap new file mode 100644 index 0000000..44161bb --- /dev/null +++ b/tests/snapshot/sentinel/undefined.sentinel.snap @@ -0,0 +1,49 @@ +># https://developer.hashicorp.com/sentinel/docs/language/undefined +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.number-sign.sentinel +> +>foo() else 42 +#^^^^^^ source.sentinel +# ^^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^^ source.sentinel constant.numeric.number.sentinel +>foo.bar else "" +#^^^^^^^^ source.sentinel +# ^^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +>config["bad-key"] else "default" +#^^^^^^^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +> +>// In more complex scenarios +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +> +>foo() else 42 == 12 +#^^^^^^ source.sentinel +# ^^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^^ source.sentinel constant.numeric.number.sentinel +# ^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^ source.sentinel constant.numeric.number.sentinel +>a = config.value else "default" +#^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^^^^^^^^^^^^ source.sentinel +# ^^^^ source.sentinel keyword.control.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +> \ No newline at end of file diff --git a/tests/snapshot/sentinel/values.sentinel b/tests/snapshot/sentinel/values.sentinel new file mode 100644 index 0000000..8c3eb42 --- /dev/null +++ b/tests/snapshot/sentinel/values.sentinel @@ -0,0 +1,51 @@ +# https://developer.hashicorp.com/sentinel/docs/language/values + +# Int +value = 42 +value = 0600 +value = 0xBadFace +value = 170141183460469 + +# Float +value = 0. +value = 72.40 +value = 072.40 // == 72.40 +value = 2.71828 +value = 1.e+0 +value = 6.67428e-11 +value = 1E6 +value = .25 +value = .12345E+5 + +# Strings +value = "\n" +value = "\"" // same as `"` +value = "Hello, world!\n" +value = "日本語" +value = "\u65e5本\U00008a9e" +value = "\xff\u00FF" +value = "\uD800" // illegal: surrogate half +value = "\U00110000" // illegal: invalid Unicode code point + +# Conversions +value = int(42) // 42 +value = int("42") // 42 +value = int(42.8) // 42 +value = int(true) // 1 + +value = float(1.2) // 1.2 +value = float(1) // 1.0 +value = float("4.2") // 4.2 +value = float(true) // 1.0 + +value = string("foo") // "foo" +value = string(88) // "88" +value = string(0xF) // "15" +value = string(true) // "true" + +value = bool("true") // true +value = bool(1) // true +value = bool(-1) // true +value = bool(0.1) // true +value = bool("false") // false +value = bool(0) // false diff --git a/tests/snapshot/sentinel/values.sentinel.snap b/tests/snapshot/sentinel/values.sentinel.snap new file mode 100644 index 0000000..ecade0d --- /dev/null +++ b/tests/snapshot/sentinel/values.sentinel.snap @@ -0,0 +1,326 @@ +># https://developer.hashicorp.com/sentinel/docs/language/values +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.number-sign.sentinel +> +># Int +#^^^^^ source.sentinel comment.line.number-sign.sentinel +>value = 42 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^ source.sentinel constant.numeric.number.sentinel +>value = 0600 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^ source.sentinel constant.numeric.oct.sentinel +>value = 0xBadFace +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^^^^^^ source.sentinel constant.numeric.hex.sentinel +>value = 170141183460469 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^^^^^^^^^^^^ source.sentinel constant.numeric.number.sentinel +> +># Float +#^^^^^^^ source.sentinel comment.line.number-sign.sentinel +>value = 0. +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +>value = 72.40 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^^ source.sentinel constant.numeric.number.sentinel +>value = 072.40 // == 72.40 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^ source.sentinel constant.numeric.oct.sentinel +# ^^^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>value = 2.71828 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^^^^ source.sentinel constant.numeric.number.sentinel +>value = 1.e+0 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^^ source.sentinel constant.numeric.number.sentinel +>value = 6.67428e-11 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^^^^^^^^ source.sentinel constant.numeric.number.sentinel +>value = 1E6 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^ source.sentinel constant.numeric.number.sentinel +>value = .25 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^ source.sentinel +# ^^ source.sentinel constant.numeric.number.sentinel +>value = .12345E+5 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^ source.sentinel +# ^^^^^^^^ source.sentinel constant.numeric.number.sentinel +> +># Strings +#^^^^^^^^^ source.sentinel comment.line.number-sign.sentinel +>value = "\n" +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel string.quoted.double.untitled constant.character.escape.single.sentinel +# ^ source.sentinel string.quoted.double.untitled +>value = "\"" // same as `"` +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel string.quoted.double.untitled constant.character.escape.single.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^^^^^^^^^^^ source.sentinel +# ^^^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>value = "Hello, world!\n" +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^^^^^^^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel string.quoted.double.untitled constant.character.escape.single.sentinel +# ^ source.sentinel string.quoted.double.untitled +>value = "日本語" +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +>value = "\u65e5本\U00008a9e" +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^ source.sentinel string.quoted.double.untitled constant.character.escape.unicode32.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^^^^ source.sentinel string.quoted.double.untitled constant.character.escape.unicode64.sentinel +# ^ source.sentinel string.quoted.double.untitled +>value = "\xff\u00FF" +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^ source.sentinel string.quoted.double.untitled constant.character.escape.hex.sentinel +# ^^^^^^ source.sentinel string.quoted.double.untitled constant.character.escape.unicode32.sentinel +# ^ source.sentinel string.quoted.double.untitled +>value = "\uD800" // illegal: surrogate half +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^ source.sentinel string.quoted.double.untitled constant.character.escape.unicode32.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^^^^^^^ source.sentinel +# ^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>value = "\U00110000" // illegal: invalid Unicode code point +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^^^^ source.sentinel string.quoted.double.untitled constant.character.escape.unicode64.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^^^^^ source.sentinel +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +> +># Conversions +#^^^^^^^^^^^^^ source.sentinel comment.line.number-sign.sentinel +>value = int(42) // 42 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^^ source.sentinel constant.numeric.number.sentinel +# ^^^^ source.sentinel +# ^^^^^ source.sentinel comment.line.double-slash.sentinel +>value = int("42") // 42 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^^^^^ source.sentinel comment.line.double-slash.sentinel +>value = int(42.8) // 42 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^^^^ source.sentinel constant.numeric.number.sentinel +# ^^ source.sentinel +# ^^^^^ source.sentinel comment.line.double-slash.sentinel +>value = int(true) // 1 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^^^^ source.sentinel constant.language.sentinel +# ^^ source.sentinel +# ^^^^ source.sentinel comment.line.double-slash.sentinel +> +>value = float(1.2) // 1.2 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^^^ source.sentinel constant.numeric.number.sentinel +# ^^^^ source.sentinel +# ^^^^^^ source.sentinel comment.line.double-slash.sentinel +>value = float(1) // 1.0 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^^^^^ source.sentinel +# ^^^^^^ source.sentinel comment.line.double-slash.sentinel +>value = float("4.2") // 4.2 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^^^^^^ source.sentinel comment.line.double-slash.sentinel +>value = float(true) // 1.0 +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^^^^ source.sentinel constant.language.sentinel +# ^^^ source.sentinel +# ^^^^^^ source.sentinel comment.line.double-slash.sentinel +> +>value = string("foo") // "foo" +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>value = string(88) // "88" +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^^ source.sentinel constant.numeric.number.sentinel +# ^^^^^ source.sentinel +# ^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>value = string(0xF) // "15" +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^^^ source.sentinel constant.numeric.hex.sentinel +# ^^^^ source.sentinel +# ^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>value = string(true) // "true" +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^^^^ source.sentinel constant.language.sentinel +# ^^^ source.sentinel +# ^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +> +>value = bool("true") // true +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel +# ^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>value = bool(1) // true +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^^^^^^^ source.sentinel +# ^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>value = bool(-1) // true +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^^^^^^ source.sentinel +# ^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>value = bool(0.1) // true +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^^^ source.sentinel constant.numeric.number.sentinel +# ^^^^^^ source.sentinel +# ^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>value = bool("false") // false +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^^ source.sentinel +# ^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>value = bool(0) // false +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^ source.sentinel support.function.builtin.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^^^^^^^ source.sentinel +# ^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +> \ No newline at end of file diff --git a/tests/snapshot/sentinel/variables.sentinel b/tests/snapshot/sentinel/variables.sentinel new file mode 100644 index 0000000..b3616b1 --- /dev/null +++ b/tests/snapshot/sentinel/variables.sentinel @@ -0,0 +1,16 @@ +# https://developer.hashicorp.com/sentinel/docs/language/variables + +a = 1 // a = 1 +b = a // b = 1 +a = "value" // a = "value", b = 1 +c = a // c = "value", b = 1 + +a = c // Error! +c = 1 + +s = "1.1" +a = int(s) // a = 1 +a = float(s) // a = 1.1 + +a = 1 +s = string(a) // s = "1" diff --git a/tests/snapshot/sentinel/variables.sentinel.snap b/tests/snapshot/sentinel/variables.sentinel.snap new file mode 100644 index 0000000..d001315 --- /dev/null +++ b/tests/snapshot/sentinel/variables.sentinel.snap @@ -0,0 +1,76 @@ +># https://developer.hashicorp.com/sentinel/docs/language/variables +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.number-sign.sentinel +> +>a = 1 // a = 1 +#^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +# ^^^^^^^ source.sentinel +# ^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>b = a // b = 1 +#^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^^^^^^^ source.sentinel +# ^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>a = "value" // a = "value", b = 1 +#^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel +# ^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>c = a // c = "value", b = 1 +#^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^^^^^^^ source.sentinel +# ^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +> +>a = c // Error! +#^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^ source.sentinel +# ^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>c = 1 +#^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +> +>s = "1.1" +#^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +>a = int(s) // a = 1 +#^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^ source.sentinel support.function.builtin.sentinel +# ^^^^^^ source.sentinel +# ^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +>a = float(s) // a = 1.1 +#^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^^ source.sentinel support.function.builtin.sentinel +# ^^^^ source.sentinel +# ^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +> +>a = 1 +#^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel constant.numeric.number.sentinel +>s = string(a) // s = "1" +#^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^^^^^^ source.sentinel support.function.builtin.sentinel +# ^^^^ source.sentinel +# ^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel +> \ No newline at end of file