Initial project import

This commit is contained in:
Agila Forge Importer committed 2026-07-13 15:20:32 +00:00
commit 23f2d29e32
11957 files changed
+1754577

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
// vtest build: amd64 || arm64
import context
const not_found_value = &Value{
val: 'key not found'
}
struct Value {
val string
}
// This example demonstrates how a value can be passed to the context
// and also how to retrieve it if it exists.
fn test_with_value() {
f := fn (ctx context.Context, key context.Key) &Value {
if value := ctx.value(key) {
match value {
Value {
return value
}
else {}
}
}
return not_found_value
}
key := 'language'
value := &Value{
val: 'VAL'
}
ctx := context.with_value(context.background(), key, value)
assert value == f(ctx, key)
assert not_found_value == f(ctx, 'color')
}