-- schema.cue --
enum: [string]:
	{"foo", #enumValue: 1} |
	{"bar", #enumValue: 2}

defEnum: [string]: #foo | #bar

#foo: 1
#bar: 2

typeEnum: [string]: #Enum

#Enum: #foo | #bar

// TODO: consider supporting @symbol(foo) or @json(,symbol=foo)
// symbolEnum: [string]:
//     { 1, @symbol(foo) } |
//     { 2, @symbol(bar) }

singleEnum: {"single", #enumValue: 1}

badEnum: {string, #enumValue: 1} | {"two", #enumValue: 2}
-- data.cue --
enum: asIs:        "foo"
enum: asIsUnknown: "foobar"

// Convert integers to string
enum: numExistFoo: 1
enum: numExistBar: 2

// Convert strings to integer
defEnum: foo: "foo"
defEnum: bar: "bar"
defEnum: baz: "baz" // unavailable

typeEnum: foo: "foo"
typeEnum: bar: "bar"
typeEnum: baz: "baz" // unavailable

// TODO: consider supporting @symbol(foo) or @json(,symbol=foo)
// symbolEnum: foo: "foo"
// symbolEnum: bar: "bar"
// symbolEnum: baz: "baz"

singleEnum: 1
-- errors.cue --
enum: numNotExists: 3

enum: numNotExists: 4

enum: tooLarge: 4_111_222_333_444_555_666_777_888_999

badEnum: 1
-- out/jsonpb/data.cue --
enum: asIs:        "foo"
enum: asIsUnknown: "foobar"

// Convert integers to string
enum: numExistFoo: "foo"
enum: numExistBar: "bar"

// Convert strings to integer
defEnum: foo: 1
defEnum: bar: 2
defEnum: baz: "baz" // unavailable

typeEnum: foo: 1
typeEnum: bar: 2
typeEnum: baz: "baz" // unavailable

// TODO: consider supporting @symbol(foo) or @json(,symbol=foo)
// symbolEnum: foo: "foo"
// symbolEnum: bar: "bar"
// symbolEnum: baz: "baz"

singleEnum: "single"
-- out/jsonpb/errors.cue --
enum.numNotExists: could not locate integer enum value 3:
    errors.cue:1:21
enum.numNotExists: could not locate integer enum value 4:
    errors.cue:3:21
enum.tooLarge: invalid enum index: 4111222333444555666777888999: greater than max int64:
    errors.cue:5:17
badEnum: invalid string enum: non-concrete value string:
    schema.cue:21:10
    schema.cue:21:11
