Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update syntax for cue 0.4.2 #11

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

update syntax for cue 0.4.2 #11

wants to merge 4 commits into from

Conversation

tmm1
Copy link

@tmm1 tmm1 commented Apr 8, 2022

I ran cue fix to fix the syntax so things compile again.

However I'm seeing this error now:

$ cue version
cue version v0.4.2 darwin/amd64

$ cue eval ./test
structural cycle:
    ./testing.cue:6:9
structural cycle:
    ./testing.cue:42:24

tmm1 added a commit to tmm1/taxes.cue that referenced this pull request Apr 8, 2022
@tmm1
Copy link
Author

tmm1 commented Apr 10, 2022

structural cycle:

I was able to fix this by changing checkTests to a definition.

Now it's getting further but hitting some other confusing errors:

test.BarBaz."6".assert.pass: conflicting values true and false:
    ./testing.cue:4:8
    ./testing.cue:5:14
    ./testing.cue:6:9
    ./testing.cue:6:50
    ./testing.cue:14:30
    ./testing.cue:22:9
    ./testing.cue:28:14
test.BarBaz."6".assert: 2 errors in empty disjunction::
    ./testing.cue:6:9
test.BarBaz."6".assert: 2 errors in empty disjunction::
    ./testing.cue:7:9

@tmm1
Copy link
Author

tmm1 commented Apr 10, 2022

I ended up reimplementing a simpler version from scratch.

#T: {
    test: [string]: {                                        
        subject: _                                           
        [string & != "subject"]: assert: {
            ok: _                                            
            pass: (*_|_ | (ok & subject)) != _|_                    
        } | {
            notOk: _ 
            pass: (*_|_ | (notOk & subject)) == _|_                    
        }
    }
    results: {
        for name, suite in test {
            let asserts = {
                for tname, x in suite if tname != "subject" {
                    (tname): x.assert.pass==true
                }
            }
            let passes = [for o, v in asserts if v == true {o}]
            if len(passes) > 0 {
                pass: (name): passes
            }
            let fails = [for o, v in asserts if v == false {o}]
            if len(fails) > 0 {
                fail: (name): fails
            }
        }
    }
}

(#T & {
    test: "simple": {
        subject: string
        "1": assert: ok: ""
        "2": assert: notOk: 1234
        "3": assert: ok: 1234
        "4": assert: notOk: ""
    }
    test: "range": {
        subject: int & >3 & <5
        "1": assert: ok: 4
        "2": assert: notOk: 2
        "3": assert: notOk: 6
    }
}).results

@tmm1
Copy link
Author

tmm1 commented Apr 10, 2022

To implement the original syntax in this repo (which allows nesting), I think one would need to use RecurseN to get past the cycle detection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant