PHP familiarity shortcuts
This commit is contained in:
+37
-37
@@ -3,12 +3,6 @@
|
||||
RENDER(Request& context)
|
||||
{
|
||||
DTree t;
|
||||
DTree assoc_left;
|
||||
DTree assoc_right;
|
||||
DTree assoc_merged;
|
||||
DTree list_left;
|
||||
DTree list_right;
|
||||
DTree list_merged;
|
||||
|
||||
<>
|
||||
<link rel="stylesheet" href='style.css'></link>
|
||||
@@ -17,25 +11,25 @@ RENDER(Request& context)
|
||||
DTree
|
||||
</h1>
|
||||
|
||||
Value Types:
|
||||
<h2>Value Types</h2>
|
||||
|
||||
<pre><?
|
||||
|
||||
t.set("String test");
|
||||
print(String("String test: ") + t.to_string()+"\n");
|
||||
print("String: ", t.to_string(), "\n");
|
||||
|
||||
t.set(true);
|
||||
print(String("bool test: ") + t.to_string()+"\n");
|
||||
print("bool: ", t.to_string(), "\n");
|
||||
|
||||
t.set(1234.5678);
|
||||
print(String("float test: ") + t.to_string()+"\n");
|
||||
print("float: ", t.to_string(), "\n");
|
||||
|
||||
t.set(&t);
|
||||
print(String("pointer test: ") + t.to_string()+"\n");
|
||||
print("pointer: ", t.to_string(), "\n");
|
||||
|
||||
?></pre>
|
||||
|
||||
Tree:
|
||||
<h2>Nested Tree</h2>
|
||||
|
||||
<pre><?
|
||||
|
||||
@@ -53,42 +47,48 @@ RENDER(Request& context)
|
||||
|
||||
?></pre>
|
||||
|
||||
Array Merge
|
||||
<h2>Array Merge — Associative</h2>
|
||||
|
||||
<pre><?
|
||||
|
||||
DTree assoc_left;
|
||||
assoc_left["name"] = "left";
|
||||
assoc_left["shared"] = "left-value";
|
||||
|
||||
DTree assoc_right;
|
||||
assoc_right["shared"] = "right-value";
|
||||
assoc_right["extra"] = "new-value";
|
||||
assoc_merged = array_merge(assoc_left, assoc_right);
|
||||
print("Associative merge:\n");
|
||||
print(var_dump(assoc_merged));
|
||||
|
||||
list_left.set_array();
|
||||
DTree a;
|
||||
a = "A";
|
||||
list_left.push(a);
|
||||
DTree b;
|
||||
b = "B";
|
||||
list_left.push(b);
|
||||
|
||||
list_right.set_array();
|
||||
DTree c;
|
||||
c = "C";
|
||||
list_right.push(c);
|
||||
DTree d;
|
||||
d = "D";
|
||||
list_right.push(d);
|
||||
|
||||
list_merged = array_merge(list_left, list_right);
|
||||
print("\nList merge:\n");
|
||||
print(var_dump(list_merged));
|
||||
print("left:\n", var_dump(assoc_left), "\n");
|
||||
print("right:\n", var_dump(assoc_right), "\n");
|
||||
print("merged:\n", var_dump(array_merge(assoc_left, assoc_right)));
|
||||
|
||||
?></pre>
|
||||
|
||||
Params
|
||||
<pre><?= var_dump(context.params) ?></pre>
|
||||
<h2>Array Merge — List</h2>
|
||||
|
||||
<pre><?
|
||||
|
||||
DTree list_left;
|
||||
list_left.set_array();
|
||||
DTree a; a = "A"; list_left.push(a);
|
||||
DTree b; b = "B"; list_left.push(b);
|
||||
|
||||
DTree list_right;
|
||||
list_right.set_array();
|
||||
DTree c; c = "C"; list_right.push(c);
|
||||
DTree d; d = "D"; list_right.push(d);
|
||||
|
||||
print("left:\n", var_dump(list_left), "\n");
|
||||
print("right:\n", var_dump(list_right), "\n");
|
||||
print("merged:\n", var_dump(array_merge(list_left, list_right)));
|
||||
|
||||
?></pre>
|
||||
|
||||
<details>
|
||||
<summary>Request Parameters</summary>
|
||||
<pre><?= var_dump(context.params) ?></pre>
|
||||
</details>
|
||||
</>
|
||||
|
||||
}
|
||||
|
||||
+80
-12
@@ -3,32 +3,100 @@
|
||||
|
||||
|
||||
|
||||
void test_row(String label, String result)
|
||||
{
|
||||
<><tr><td class="test-label"><?= label ?></td><td class="test-result"><code><?= result ?></code></td></tr></>
|
||||
}
|
||||
|
||||
void test_row(String label, String result, String expect)
|
||||
{
|
||||
bool pass = (result == expect);
|
||||
<><tr>
|
||||
<td class="test-label"><?= label ?></td>
|
||||
<td class="test-result"><code><?= result ?></code></td>
|
||||
<td class="test-status <?= pass ? "pass" : "fail" ?>"><?= pass ? "✓" : "✗ expected: " + expect ?></td>
|
||||
</tr></>
|
||||
}
|
||||
|
||||
void test_num(String label, s64 result, s64 expect)
|
||||
{
|
||||
bool pass = (result == expect);
|
||||
<><tr>
|
||||
<td class="test-label"><?= label ?></td>
|
||||
<td class="test-result"><code><? print(result); ?></code></td>
|
||||
<td class="test-status <?= pass ? "pass" : "fail" ?>"><? if(!pass) { print("✗ expected: "); print(expect); } else { print("✓"); } ?></td>
|
||||
</tr></>
|
||||
}
|
||||
|
||||
RENDER(Request& context)
|
||||
{
|
||||
String sample = " Hello UCE World ";
|
||||
|
||||
<>
|
||||
<link rel="stylesheet" href='style.css'></link>
|
||||
<style>
|
||||
table.tests { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
|
||||
table.tests td { padding: 6px 12px; border-bottom: 1px solid rgba(255,255,255,0.06); font-family: var(--font-mono); font-size: 0.88rem; }
|
||||
.test-label { color: var(--text-dim); white-space: nowrap; width: 1%; }
|
||||
.test-result code { background: var(--bg-code); padding: 2px 8px; border-radius: 4px; }
|
||||
.test-status.pass { color: #6f6; width: 1%; }
|
||||
.test-status.fail { color: #f66; }
|
||||
</style>
|
||||
<h1>
|
||||
<a href="index.uce">UCE Test</a>:
|
||||
Strings
|
||||
</h1>
|
||||
|
||||
<pre style="white-space: pre-wrap"><?
|
||||
<p>sample = <code>"<?= sample ?>"</code></p>
|
||||
|
||||
print("sample: [", sample, "]\n");
|
||||
print("trim(sample): [", trim(sample), "]\n");
|
||||
print("substr(sample, 2, 5): [", substr(sample, 2, 5), "]\n");
|
||||
print("substr(sample, -7): [", substr(sample, -7), "]\n");
|
||||
print("strpos(sample, \"UCE\"): ", strpos(sample, "UCE"), "\n");
|
||||
print("contains(sample, \"World\"): ", contains(sample, "World") ? "true" : "false", "\n");
|
||||
print("str_starts_with(trim(sample), \"Hello\"): ", str_starts_with(trim(sample), "Hello") ? "true" : "false", "\n");
|
||||
print("str_ends_with(trim(sample), \"World\"): ", str_ends_with(trim(sample), "World") ? "true" : "false", "\n");
|
||||
<h2>trim</h2>
|
||||
<table class="tests"><?
|
||||
test_row("trim(sample)", "[" + trim(sample) + "]", "[Hello UCE World]");
|
||||
?></table>
|
||||
|
||||
?></pre>
|
||||
<h2>substr</h2>
|
||||
<table class="tests"><?
|
||||
test_row("substr(sample, 2, 5)", substr(sample, 2, 5), "Hello");
|
||||
test_row("substr(sample, -7)", substr(sample, -7), "World ");
|
||||
test_row("substr(sample, 2, -2)", substr(sample, 2, -2), "Hello UCE World");
|
||||
?></table>
|
||||
|
||||
Params
|
||||
<pre><?= var_dump(context.params) ?></pre>
|
||||
<h2>strpos</h2>
|
||||
<table class="tests"><?
|
||||
test_num("strpos(sample, \"UCE\")", strpos(sample, "UCE"), 8);
|
||||
test_num("strpos(sample, \"missing\")", strpos(sample, "missing"), -1);
|
||||
?></table>
|
||||
|
||||
<h2>contains</h2>
|
||||
<table class="tests"><?
|
||||
test_row("contains(sample, \"World\")", contains(sample, "World") ? "true" : "false", "true");
|
||||
test_row("contains(sample, \"xyz\")", contains(sample, "xyz") ? "true" : "false", "false");
|
||||
?></table>
|
||||
|
||||
<h2>str_starts_with / str_ends_with</h2>
|
||||
<table class="tests"><?
|
||||
test_row("str_starts_with(trim(sample), \"Hello\")", str_starts_with(trim(sample), "Hello") ? "true" : "false", "true");
|
||||
test_row("str_starts_with(trim(sample), \"World\")", str_starts_with(trim(sample), "World") ? "true" : "false", "false");
|
||||
test_row("str_ends_with(trim(sample), \"World\")", str_ends_with(trim(sample), "World") ? "true" : "false", "true");
|
||||
test_row("str_ends_with(trim(sample), \"Hello\")", str_ends_with(trim(sample), "Hello") ? "true" : "false", "false");
|
||||
?></table>
|
||||
|
||||
<h2>replace / split / join</h2>
|
||||
<table class="tests"><?
|
||||
test_row("replace(sample, \"UCE\", \"C++\")", replace(sample, "UCE", "C++"), " Hello C++ World ");
|
||||
test_row("join(split(trim(sample), \" \"), \"-\")", join(split(trim(sample), " "), "-"), "Hello-UCE-World");
|
||||
?></table>
|
||||
|
||||
<h2>to_upper / to_lower</h2>
|
||||
<table class="tests"><?
|
||||
test_row("to_upper(trim(sample))", to_upper(trim(sample)), "HELLO UCE WORLD");
|
||||
test_row("to_lower(trim(sample))", to_lower(trim(sample)), "hello uce world");
|
||||
?></table>
|
||||
|
||||
<details>
|
||||
<summary>Request Parameters</summary>
|
||||
<pre><?= var_dump(context.params) ?></pre>
|
||||
</details>
|
||||
</>
|
||||
|
||||
}
|
||||
|
||||
+45
-24
@@ -1,24 +1,28 @@
|
||||
/* UCE Test Suite — Theme
|
||||
Color palette: #139 deep-blue base · white text · yellow accents */
|
||||
Color palette: deep blue gradient · warm gold accents · frosted glass surfaces */
|
||||
|
||||
:root {
|
||||
--bg: #113399;
|
||||
--bg-surface: rgba(255, 255, 255, 0.065);
|
||||
--bg-surface-hover: rgba(255, 255, 255, 0.11);
|
||||
--bg-inset: rgba(0, 0, 0, 0.22);
|
||||
--bg-code: rgba(0, 0, 0, 0.28);
|
||||
--text: #e8ecf4;
|
||||
--text-dim: rgba(255, 255, 255, 0.55);
|
||||
--text-muted: rgba(255, 255, 255, 0.35);
|
||||
--accent: #ffd644;
|
||||
--accent-dim: rgba(255, 214, 68, 0.1);
|
||||
--accent-hover: #ffe680;
|
||||
--border: rgba(255, 255, 255, 0.08);
|
||||
--border-strong: rgba(255, 255, 255, 0.18);
|
||||
--font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
|
||||
--font-mono: 'SF Mono', 'Cascadia Code', 'Fira Code', Consolas, monospace;
|
||||
--radius: 8px;
|
||||
--radius-lg: 14px;
|
||||
--bg: #0b1d4e;
|
||||
--bg-grad: linear-gradient(168deg, #0f2462 0%, #0b1d4e 40%, #091840 100%);
|
||||
--bg-surface: rgba(255, 255, 255, 0.05);
|
||||
--bg-surface-hover: rgba(255, 255, 255, 0.09);
|
||||
--bg-inset: rgba(0, 0, 0, 0.3);
|
||||
--bg-code: rgba(0, 0, 0, 0.32);
|
||||
--text: #dfe5f2;
|
||||
--text-dim: rgba(200, 210, 235, 0.6);
|
||||
--text-muted: rgba(200, 210, 235, 0.35);
|
||||
--accent: #f0c430;
|
||||
--accent-dim: rgba(240, 196, 48, 0.08);
|
||||
--accent-hover: #ffd95c;
|
||||
--accent-glow: rgba(240, 196, 48, 0.15);
|
||||
--border: rgba(255, 255, 255, 0.06);
|
||||
--border-strong: rgba(255, 255, 255, 0.14);
|
||||
--shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
|
||||
--shadow-md: 0 4px 16px rgba(0, 0, 0, 0.25);
|
||||
--font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
|
||||
--font-mono: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', 'Fira Code', Consolas, monospace;
|
||||
--radius: 10px;
|
||||
--radius-lg: 16px;
|
||||
--ease: cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
@@ -52,8 +56,10 @@ body {
|
||||
font-family: var(--font-sans);
|
||||
font-size: 1rem;
|
||||
line-height: 1.65;
|
||||
background: var(--bg);
|
||||
background: var(--bg-grad);
|
||||
background-attachment: fixed;
|
||||
color: var(--text);
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
/* ── Typography ── */
|
||||
@@ -63,8 +69,9 @@ h1 {
|
||||
font-size: 1.6rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.02em;
|
||||
padding: 28px 0 20px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
padding: 32px 0 20px;
|
||||
border-bottom: 2px solid transparent;
|
||||
border-image: linear-gradient(90deg, var(--accent) 0%, rgba(240, 196, 48, 0.15) 100%) 1;
|
||||
margin-bottom: 28px;
|
||||
}
|
||||
|
||||
@@ -117,10 +124,13 @@ body > section,
|
||||
body > div:not(.test-grid):not(.system-info):not(.grid-heading),
|
||||
body > p {
|
||||
background: var(--bg-surface);
|
||||
backdrop-filter: blur(12px);
|
||||
-webkit-backdrop-filter: blur(12px);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
padding: 20px 24px;
|
||||
margin-bottom: 16px;
|
||||
box-shadow: var(--shadow-sm);
|
||||
}
|
||||
|
||||
/* ── Test Card Grid ── */
|
||||
@@ -138,18 +148,22 @@ body > p {
|
||||
gap: 4px;
|
||||
padding: 16px 20px;
|
||||
background: var(--bg-surface);
|
||||
backdrop-filter: blur(12px);
|
||||
-webkit-backdrop-filter: blur(12px);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
text-decoration: none;
|
||||
color: var(--text);
|
||||
transition: all 150ms var(--ease);
|
||||
box-shadow: var(--shadow-sm);
|
||||
transition: all 200ms var(--ease);
|
||||
}
|
||||
|
||||
.test-card:hover {
|
||||
background: var(--bg-surface-hover);
|
||||
border-color: var(--border-strong);
|
||||
text-decoration: none;
|
||||
transform: translateY(-1px);
|
||||
transform: translateY(-2px);
|
||||
box-shadow: var(--shadow-md);
|
||||
}
|
||||
|
||||
.test-card strong {
|
||||
@@ -263,8 +277,9 @@ pre {
|
||||
border-radius: var(--radius);
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.85rem;
|
||||
line-height: 1.55;
|
||||
line-height: 1.6;
|
||||
white-space: pre-wrap;
|
||||
box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
|
||||
code {
|
||||
@@ -302,8 +317,11 @@ li a {
|
||||
margin-top: 32px;
|
||||
padding: 16px 20px;
|
||||
background: var(--bg-code);
|
||||
backdrop-filter: blur(12px);
|
||||
-webkit-backdrop-filter: blur(12px);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
box-shadow: var(--shadow-sm);
|
||||
}
|
||||
|
||||
.system-info h3 {
|
||||
@@ -322,9 +340,12 @@ li a {
|
||||
|
||||
details {
|
||||
background: var(--bg-surface);
|
||||
backdrop-filter: blur(12px);
|
||||
-webkit-backdrop-filter: blur(12px);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
margin-bottom: 16px;
|
||||
box-shadow: var(--shadow-sm);
|
||||
}
|
||||
|
||||
summary {
|
||||
|
||||
Reference in New Issue
Block a user