MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / test_expressions

Function test_expressions

subprojects/llama.cpp/tests/test-jinja.cpp:363–435  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

361}
362
363static void test_expressions(testing & t) {
364 test_template(t, "simple variable",
365 "{{ x }}",
366 {{"x", 42}},
367 "42"
368 );
369
370 test_template(t, "dot notation",
371 "{{ user.name }}",
372 {{"user", {{"name", "Bob"}}}},
373 "Bob"
374 );
375
376 test_template(t, "negative float (not dot notation)",
377 "{{ -1.0 }}",
378 json::object(),
379 "-1.0"
380 );
381
382 test_template(t, "bracket notation",
383 "{{ user['name'] }}",
384 {{"user", {{"name", "Bob"}}}},
385 "Bob"
386 );
387
388 test_template(t, "array access",
389 "{{ items[1] }}",
390 {{"items", json::array({"a", "b", "c"})}},
391 "b"
392 );
393
394 test_template(t, "array negative access",
395 "{{ items[-1] }}",
396 {{"items", json::array({"a", "b", "c"})}},
397 "c"
398 );
399
400 test_template(t, "array slice",
401 "{{ items[1:-1]|string }}",
402 {{"items", json::array({"a", "b", "c"})}},
403 "['b']"
404 );
405
406 test_template(t, "array slice step",
407 "{{ items[::2]|string }}",
408 {{"items", json::array({"a", "b", "c"})}},
409 "['a', 'c']"
410 );
411
412 test_template(t, "tuple slice",
413 "{{ ('a', 'b', 'c')[::-1]|string }}",
414 json::object(),
415 "('c', 'b', 'a')"
416 );
417
418 test_template(t, "arithmetic",
419 "{{ (a + b) * c }}",
420 {{"a", 2}, {"b", 3}, {"c", 4}},

Callers

nothing calls this directly

Calls 1

test_templateFunction · 0.85

Tested by

no test coverage detected