diff --git a/test/array/run.t b/test/array/run.t
index df9c83a..9904718 100644
--- a/test/array/run.t
+++ b/test/array/run.t
@@ -42,3 +42,94 @@
12347
+
+ $ pincfmt ./data.pi
+ component C() {
+ use Base;
+
+ let array = 0...3;
+ let new_array = array @ 4;
+ let new_array_2 = array @ 4 @ 5 @ 6;
+
+ let merged_array = new_array @@ 5...7;
+ let merged_array_2 = new_array @@ 5...7 @@ [8, 9];
+
+ let merged_record = {
+ a: 1,
+ b: 2,
+ } @@ {
+ c: 3,
+ };
+ let merged_record_2 = {
+ a: 1,
+ b: 2,
+ } @@ {
+ b: 3,
+ } @@ {
+ y: 8,
+ };
+
+ let nested_array = new_array @ (merged_array @ merged_record_2);
+ let index = 8;
+
+ let partitioned = merged_array_2 |> Array.partition(fn (item) -> { item % 2 == 0 });
+ let even = partitioned[0];
+ let odd = partitioned[1];
+
+
+ {array}
+
+ {new_array}
+
+ {new_array_2}
+
+ {merged_array}
+
+ {merged_array_2}
+
+ {merged_record}
+ {merged_record_2}
+
+ {nested_array[2 + 3 * 1][index]["y"]}
+ {nested_array[2 + 3 * 1][index].y}
+
+ {even}
+
+ {odd}
+
+ {merged_array_2 |> Array.keep(fn (item) -> { item % 2 == 0 })}
+
+ {if (merged_array_2 |> Array.find(fn (item) -> { item == 3 })) {
+ "FOUND"
+ } else {
+ "NOT FOUND"
+ }}
+
+ {if (merged_array_2 |> Array.find(fn (item) -> { item == -10 })) {
+ "FOUND"
+ } else {
+ "NOT FOUND"
+ }}
+
+ {even |> Array.every(fn (item) -> { item % 2 == 0 })}
+ {merged_array_2 |> Array.some(fn (item) -> { item % 2 == 0 })}
+ {merged_array_2 |> Array.every(fn (item) -> { item % 2 == 0 })}
+ {merged_array_2 |> Array.some(fn (item) -> { item < 0 })}
+ {Array.make(6) |> Array.map(fn (item) -> item + 1) |> Array.reduce(
+ 0,
+ fn (acc, item) -> item + acc,
+ )}
+
+ {merged_array_2 |> Array.take_until(fn (item) -> item == 5)}
+
+ {1...10 |> Array.slice(2, 5)}
+
+ {["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"] |> Array.chunk(3) |> Array.map(
+ fn (chunk) -> Array.join(chunk, ","),
+ ) |> Array.map(fn (item) -> {item}
)}
+
+ {[5, 1, 2, 3, 6, 3, 4, 7] |> Array.sort(fn (a, b) -> a - b)}
+
+ {[1, 1, 2, 3, 4, 3, 4, 7] |> Array.unique}
+
+ }
diff --git a/test/char/run.t b/test/char/run.t
index 246169f..78a3697 100644
--- a/test/char/run.t
+++ b/test/char/run.t
@@ -22,3 +22,32 @@
😡
+ $ pincfmt ./data.pi
+ component C() {
+ use Base;
+
+ let char = 'c';
+
+
+ String.uppercase_ascii("abcàäöüß"): {String.uppercase_ascii("abcàäöüß")}
+ String.lowercase_ascii("ABCÁÄÖÜß"): {String.lowercase_ascii("ABCÁÄÖÜß")}
+ String.capitalize_ascii("abc"): {String.capitalize_ascii("abc")}
+ String.capitalize_ascii("äöü"): {String.capitalize_ascii("äöü")}
+
+ char: {char}
+ char + 1: {char + 1}
+ char < 32: {char < 32}
+ char > 32: {char > 32}
+
+ {' ' + 1}
+ {' ' + 1}
+ {'\'}
+ {'
+ '}
+ {'''}
+ {' '}
+ {'©'}
+ {'ǿ'}
+ {'!' + 128512}
+
+ }
diff --git a/test/component/run.t b/test/component/run.t
index 9811ed5..3da0628 100644
--- a/test/component/run.t
+++ b/test/component/run.t
@@ -55,3 +55,55 @@
}
+
+ $ pincfmt ./Matrix.pi
+ component Matrix() {
+ let matrix = #Array(of: #Array(of: #Int));
+
+
+ {for (row in matrix) {
+
+ {for (col in row) {
+ - {col}
+ }}
+
+ }}
+
+ }
+
+ $ pincfmt ./Sub/SubComponent.pi
+ component HeadlineSecondary() {
+ let class? = #String;
+
+ let tag? = #String :: fn (value) -> value |> Base.Fn.default("h3");
+
+ let data = #Record(
+ of: {
+ text: if (tag == "h2") #String else "No no no ... make h2 when you want text",
+ subheadline?: if (tag == "h2") #String,
+ },
+ );
+
+ let class = "HeadlineSecondary $(class)";
+
+ let content = <>
+ {if (data.subheadline) }
+ {data.text}
+ >;
+
+ if (tag == "h1") {
+ {content}
+ } else if (tag == "h2") {
+ {content}
+ } else if (tag == "h3") {
+ {content}
+ } else if (tag == "h4") {
+ {content}
+ } else if (tag == "h5") {
+ {content}
+ } else if (tag == "h6") {
+ {content}
+ } else {
+ "INVALID TAG!"
+ }
+ }
diff --git a/test/context/run.t b/test/context/run.t
index 6066aad..5c6cd3d 100644
--- a/test/context/run.t
+++ b/test/context/run.t
@@ -8,3 +8,66 @@
+
+ $ pincfmt ./data.pi
+ component Component(
+ label: "Section",
+ icon: "/images/icons/group.svg",
+ group: "Structure",
+ ) {
+ #SetContext(key: "background", value: "grey")
+
+
+ }
+
+ $ pincfmt ./HeadlineSecondary.pi
+ component HeadlineSecondary() {
+ #SetContext(key: "test", value: "should never be displayed!")
+
+ let class? = #String :: fn (value) -> if (!value) "";
+
+ let tag? = #String :: fn (value) -> if (!value) "h3";
+ let data = {
+ text: #String,
+ subheadline?: #String,
+ };
+
+ let class = "HeadlineSecondary $(class)";
+
+ let content = <>
+ {if (data.subheadline) }
+ {data.text}
+ >;
+
+ if (tag == "h1") {
+ {content}
+ } else if (tag == "h2") {
+ {content}
+ } else if (tag == "h3") {
+ {content}
+ } else if (tag == "h4") {
+ {content}
+ } else if (tag == "h5") {
+ {content}
+ } else if (tag == "h6") {
+ {content}
+ } else {
+ "INVALID TAG!"
+ }
+ }
+
+ $ pincfmt ./SubComponent.pi
+ component SubComponent() {
+ let background = #GetContext;
+ let test? = #GetContext;
+
+ let backgroundClass = if (background == "grey") "Sub--grey" else "";
+
+
+
Faucibus mus velit ut iaculis cubilia taciti conubia, ad magna sem mattis tincidunt eleifend, egestas eget neque curae molestie donec. Magna ipsum netus euismod vitae justo dictum adipiscing lobortis, posuere tortor penatibus tempus laoreet habitant orci, turpis blandit nullam ornare fames nostra sed.
+
{test}
+
+ }
diff --git a/test/function/run.t b/test/function/run.t
index 42082e0..0be0cf2 100644
--- a/test/function/run.t
+++ b/test/function/run.t
@@ -21,3 +21,105 @@
Map Pipe:
14916
+
+ $ pincfmt ./data.pi
+ component Component() {
+ use C = Math.Constants;
+
+ let max = fn (a, b) -> {
+ if (a > b) {
+ a
+ } else {
+ b
+ }
+ };
+
+ let min = fn (a, b) -> {
+ if (a < b) {
+ a
+ } else {
+ b
+ }
+ };
+
+ let until = 5;
+ let map = fn (array, f) -> {
+ for (el in array) {
+ if (min(el, until) == until) {
+ continue;
+ }
+
+ f(el)
+ }
+ };
+
+ let add_curry = fn (a) -> {
+ fn (b) -> {
+ a + b
+ }
+ };
+
+ let is_even = fn (i) -> {
+ if (i == 0) {
+ true
+ } else {
+ is_odd(i - 1)
+ }
+ };
+
+ let is_odd = fn (i) -> {
+ if (i == 0) {
+ false
+ } else {
+ is_even(i - 1)
+ }
+ };
+
+
+ max(1, 5) = {max(1, 5)}
+ min(1, 5) = {min(1, 5)}
+ add_curry(1)(5) = {add_curry(1)(5)}
+ Math.fibonacci(9) = {Math.fibonacci(9)}
+ Math.factorial(5) = {Math.factorial(5)}
+ is_even(10) = {is_even(10)}
+ is_odd(10) = {is_odd(10)}
+
+ 1 |> max(5) |> Math.factorial = {1 |> max(5) |> Math.factorial}
+ 1 |> add_curry(5)() = {1 |> add_curry(5)()}
+ 5 |> Math.factorial = {5 |> Math.factorial}
+
+ Math.Constants.pi = {Math.Constants.pi}
+ C.pi = {C.pi}
+
+ Map:
+ {map(1...10, fn (item) -> item ** 2)}
+
+ Map Pipe:
+ {1...10 |> map(fn (item) -> item ** 2)}
+
+ }
+
+ $ pincfmt ./library.pi
+ library Math() {
+ use Constants = Math__Constants;
+
+ let fibonacci = fn (n) -> {
+ if (n <= 1) {
+ n
+ } else {
+ fibonacci(n - 1) + fibonacci(n - 2)
+ }
+ };
+
+ let factorial = fn (n) -> {
+ if (n <= 1) {
+ 1
+ } else {
+ n * factorial(n - 1)
+ }
+ };
+ }
+
+ library Math__Constants() {
+ let pi = 3.1415;
+ }
diff --git a/test/loop/run.t b/test/loop/run.t
index e0d153e..f322d04 100644
--- a/test/loop/run.t
+++ b/test/loop/run.t
@@ -76,3 +76,145 @@
012
+
+ $ pincfmt ./data.pi
+ component Component() {
+
+ let max = 10;
+
+ let array = 0..max;
+
+ let string_array = ["one", "two", "three", "!"];
+
+ let null_value? = if (false) "something";
+
+
+ EXCLUSIVE RANGES
+
+ 0..10
+ {for (i in 0..10) {
+ {i}
+ }}
+
+ 0..0
+ {for (i in 0..0) {
+ {i}
+ }}
+
+ 0..1
+ {for (i in 0..1) {
+ {i}
+ }}
+
+ 0..-1
+ {for (i in 0..-1) {
+ {i}
+ }}
+
+ -10..10
+ {for (i in -10..10) {
+ {i}
+ }}
+
+ 10..0
+ {for (i in 10..0) {
+ {i}
+ }}
+
+ 0..10 reverse
+ {for (i in reverse 0..10) {
+ {i}
+ }}
+
+
+ INCLUSIVE RANGES
+
+ 0...10
+ {for (i in 0...10) {
+ {i}
+ }}
+
+ 0...0
+ {for (i in 0...0) {
+ {i}
+ }}
+
+ 0...1
+ {for (i in 0...1) {
+ {i}
+ }}
+
+ 0...-1
+ {for (i in 0...-1) {
+ {i}
+ }}
+
+ -10...10
+ {for (i in -10...10) {
+ {i}
+ }}
+
+ 10...0
+ {for (i in 10...0) {
+ {i}
+ }}
+
+ 0...10 reverse
+ {for (i in reverse 0...10) {
+ {i}
+ }}
+
+
+ ITERABLES
+
+ array
+ {for (i in array) {
+ {i}
+ }}
+
+ array reverse
+ {for (i in reverse array) {
+ {i}
+ }}
+
+ string
+ {for (c in "String!") {
+ {c}
+ }}
+
+ string reverse
+ {for (c in reverse "Sträinèg!") {
+ {c}
+ }}
+
+ string array
+ {for (index, s in string_array) {
+ {index} {s}
+ }}
+
+ null value
+ {for (s in null_value) {
+ {s}
+ }}
+
+
+ BREAK / CONTINUE
+
+ {for (c in "String!") {
+ if (c == 'i') {
+ continue;
+ }
+
+ c
+ }}
+
+ {for (i in 0..5) {
+ if (i == 3) {
+ break;
+ }
+
+ i
+ }}
+
+
+ }
diff --git a/test/mutation/run.t b/test/mutation/run.t
index 374ea51..049a6f3 100644
--- a/test/mutation/run.t
+++ b/test/mutation/run.t
@@ -5,3 +5,30 @@
print_c(): mutated
print_d(): initial
+
+ $ pincfmt ./data.pi
+ component Component() {
+ let mutable a = "initial";
+ a := "mutated";
+
+ let mutable b = "initial";
+ if (a == "mutated") {
+ b := "mutated";
+ }
+
+ let mutable c = "initial";
+ let print_c = fn () -> c;
+ c := "mutated";
+
+ let mutable d = "initial";
+ let print_d = fn () -> d;
+ let mutable d = "initial2";
+ d := "mutated";
+
+
+ a: {a}
+ b: {b}
+ print_c(): {print_c()}
+ print_d(): {print_d()}
+
+ }
diff --git a/test/operators/run.t b/test/operators/run.t
index d572c1e..dcba770 100644
--- a/test/operators/run.t
+++ b/test/operators/run.t
@@ -75,3 +75,82 @@
(5 * 3) + 2 / 6 + 4 * 8 ** 10 = 4294967311.33
+
+ $ pincfmt ./data.pi
+ component Component() {
+
+ ![1] = {![1]}
+ ![] = {![]}
+ !!"" = {!!""}
+ !true = {!true}
+ -1 = {-1}
+ -2.5 = {-2.5}
+
+ true == true = {true == true}
+ true != true = {true != true}
+ true && true = {true && true}
+ true && false = {true && false}
+ true || false = {true || false}
+ false || false = {false || false}
+ true || true && false = {true || true && false}
+ false && true || true = {false && true || true}
+
+ 1 == 1 = {1 == 1}
+ 1 == 2 = {1 == 2}
+ 1 > 2 = {1 > 2}
+ 1 < 2 = {1 < 2}
+ 1 <= 1 = {1 <= 1}
+ 2 <= 1 = {2 <= 1}
+ 1 >= 1 = {1 >= 1}
+
+ [1] == [1] = {[1] == [1]}
+ [1] == [2] = {[1] == [2]}
+ [1, 2] >= [5] = {[1, 2] >= [5]}
+ [1] >= [1,2,3] = {[1] >= [1, 2, 3]}
+
+ 1 + 1 = {1 + 1}
+ 1.3 + 1.5 = {1.3 + 1.5}
+ 1 + 1.2 = {1 + 1.2}
+ 2.73 + 3 = {2.73 + 3}
+
+ 1 - 1 = {1 - 1}
+ 1.3 - 1.5 = {1.3 - 1.5}
+ 1 - 1.2 = {1 - 1.2}
+ 2.73 - 3 = {2.73 - 3}
+
+ 1 * 1 = {1 * 1}
+ 1.3 * 1.5 = {1.3 * 1.5}
+ 1 * 1.2 = {1 * 1.2}
+ 2.73 * 3 = {2.73 * 3}
+ 10 * -1 = {10 * -1}
+
+ 1 / 1 = {1 / 1}
+ 1.3 / 1.5 = {1.3 / 1.5}
+ 1 / 1.2 = {1 / 1.2}
+ 2.73 / 3 = {2.73 / 3}
+
+ 3 ** 1 = {3 ** 1}
+ 3 ** 2 = {3 ** 2}
+ 3 ** 3 = {3 ** 3}
+ 2.73 ** 3 = {2.73 ** 3}
+
+ "a" ++ "b" = {"a" ++ "b"}
+ "a" ++ "b" ++ "c" = {"a" ++ "b" ++ "c"}
+
+ 5 % 2 = {5 % 2}
+ 5 % 3 = {5 % 3}
+
+ 3 - 2 + 4 * -5 = {3 - 2 + 4 * -5}
+ 3 - -5 + 4 * 2 = {3 - -5 + 4 * 2}
+ -5 * 3 + 4 * 2 = {-5 * 3 + 4 * 2}
+ 2 + 3 * 5 = {2 + 3 * 5}
+ 5 * 3 + 2 = {5 * 3 + 2}
+ 2 ** 3 ** 2 = {2 ** 3 ** 2}
+ 2 ** 3 * 5 = {2 ** 3 * 5}
+ 3 * 5 ** 2 = {3 * 5 ** 2}
+ 5 * 3 + 2 / 6 + 4 * 8 ** 10 = {5 * 3 + 2 / 6 + 4 * 8 ** 10}
+ 5 * 3 + 2 / (6 + 4) * 8 ** 10 = {5 * 3 + 2 / (6 + 4) * 8 ** 10}
+ 5 * 3 + 2 / (6 + 4 * 8) ** 10 = {5 * 3 + 2 / (6 + 4 * 8) ** 10}
+ (5 * 3) + 2 / 6 + 4 * 8 ** 10 = {(5 * 3) + 2 / 6 + 4 * 8 ** 10}
+
+ }
diff --git a/test/optional_record_tags/run.t b/test/optional_record_tags/run.t
index 1a6051e..5d11ca6 100644
--- a/test/optional_record_tags/run.t
+++ b/test/optional_record_tags/run.t
@@ -2,3 +2,27 @@
"lorem" & ""
+ $ pincfmt ./data.pi
+ page Docs() {
+ <>
+
+ >
+ }
+
+ component Sub() {
+ let attributes = #Record(
+ of: {
+ bar: #String,
+ lorem?: #String(key: "foo"),
+ },
+ );
+
+ "{attributes.bar}" & "{attributes.lorem}"
+ }
diff --git a/test/portal/run.t b/test/portal/run.t
index 9f89e39..4f7f82d 100644
--- a/test/portal/run.t
+++ b/test/portal/run.t
@@ -7,3 +7,43 @@