# Tests basic passing assertions: eq, err, kind=, closed, builtin validators,
# and selector references. Each case exercises a distinct directive handler in
# the inline runner's runDirective dispatcher.
-- in/test.cue --
import (
	"math"
	"struct"
)

// eq: concrete values
intEq: 42      @test(eq, 42)
strEq: "hello" @test(eq, "hello")

// err: conflict error detected
errField: 1 & 2 @test(err, code=eval,
	contains="conflicting values %s and %s", args=[2, 1], pos=[0:11, 0:15]
)

// kind=: abstract type check
kindInt:     int @test(kind=int)
kindIntFail: int @test(kind=string)

// closed: close({}) makes struct closed
closedStruct: close({a: 1}) @test(closed)

// eq: builtin validator call expression
minFields: struct.MinFields(0) & {} @test(eq, {})

// eq: selector reference (math.Pi)
piField: math.Pi @test(eq, math.Pi)

// eq: incomplete field in struct — incompleteA.b is abstract, so incompleteA.b+3 is _|_
incompleteA: {b: int}
incompleteC: incompleteA & {b: 100, d: incompleteA.b + 3} @test(eq, {b: 100, d: _|_})
-- out/status.txt --
update: output passes run
force:  identical to update
-- out/run/errors.txt --
path kindIntFail: @test(kind=string): got kind int, want string
-- out/update/test.cue --
import (
	"math"
	"struct"
)

// eq: concrete values
intEq: 42      @test(eq, 42)
strEq: "hello" @test(eq, "hello")

// err: conflict error detected
errField: 1 & 2 @test(err, code=eval,
	contains="conflicting values %s and %s", args=[2, 1], pos=[0:11, 0:15]
)

// kind=: abstract type check
kindInt:     int @test(kind=int)
kindIntFail: int @test(kind=string)

// closed: close({}) makes struct closed
closedStruct: close({a: 1}) @test(closed)

// eq: builtin validator call expression
minFields: struct.MinFields(0) & {} @test(eq, {})

// eq: selector reference (math.Pi)
piField: math.Pi @test(eq, math.Pi)

// eq: incomplete field in struct — incompleteA.b is abstract, so incompleteA.b+3 is _|_
incompleteA: {b: int}
incompleteC: incompleteA & {b: 100, d: incompleteA.b + 3} @test(eq, {b: 100, d: _|_})
-- out/update/out/errors.txt --
[eval] errField: conflicting values 2 and 1:
    ./test.cue:11:11
    ./test.cue:11:15
[incomplete] incompleteC.d: non-concrete value int in operand to +:
    ./test.cue:30:40
    ./test.cue:29:18
