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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

The testable example "ExampleContext" is not testing output #1267

Closed
ameowlia opened this issue Sep 21, 2021 · 3 comments
Closed

The testable example "ExampleContext" is not testing output #1267

ameowlia opened this issue Sep 21, 2021 · 3 comments
Labels
NeedsInvestigation Triage Requires triage/attention

Comments

@ameowlia
Copy link
Contributor

馃憢 Hello,

I am investigating the golang issue: golang/go#48362, where testable examples are causing false positives when the output comment block is not the last comment block example.

I ran a parser against the top golang repos, including this repo, and I found this bug with your ExampleContext testable example.

The output comment blocks at the end should be combined like so:

func ExampleContext() {
	ctx := cuecontext.New()

	v := ctx.CompileString(`
		a: 2
		b: 3
		"a+b": a + b
	`)

	p("lookups")
	p("a:     %v", v.LookupPath(cue.ParsePath("a")))
	p("b:     %v", v.LookupPath(cue.ParsePath("b")))
	p(`"a+b": %v`, v.LookupPath(cue.ParsePath(`"a+b"`)))
	p("")
	p("expressions")
	p("a + b: %v", ctx.CompileString("a + b", cue.Scope(v)))
	p("a * b: %v", ctx.CompileString("a * b", cue.Scope(v)))

	// Output:
	// lookups
	// a:     2
	// b:     3
	// "a+b": 5
	//
	// expressions
	// a + b: 5
	// a * b: 6
}

I am happy to PR this in, but it will take a few days for me to get approval from my employer before I can submit it.

@mpvl
Copy link
Member

mpvl commented Oct 26, 2021

I am happy to PR this in, but it will take a few days for me to get approval from my employer before I can submit it.

Great!

@mpvl mpvl removed the Triage Requires triage/attention label Oct 26, 2021
@ameowlia
Copy link
Contributor Author

I'm seeing you all over the place @mpvl 馃槃 . PR (finally) sent.

@myitcv myitcv added the Triage Requires triage/attention label Nov 19, 2021
@mpvl
Copy link
Member

mpvl commented Nov 24, 2021

@ameowlia Indeed. :) Thanks for the PR.

The PR importer is broken at the moment, but will submit asap.

cueckoo pushed a commit that referenced this issue Nov 25, 2021
If the output comment block of a testable example is not the last
comment block then nothing will be tested. This commit combines the
comment blocks so that the example actually tests against the output.

Fixes #1267
Closes #1385

Signed-off-by: Amelia Downs <adowns@vmware.com>
Change-Id: I2e1d6f0e6445053988f88ff50249071f40744851
cueckoo pushed a commit that referenced this issue Nov 25, 2021
If the output comment block of a testable example is not the last
comment block then nothing will be tested. This commit combines the
comment blocks so that the example actually tests against the output.

Fixes #1267
Closes #1385

Signed-off-by: Amelia Downs <adowns@vmware.com>
Change-Id: I2e1d6f0e6445053988f88ff50249071f40744851
jlongtine pushed a commit to jlongtine/cue that referenced this issue Dec 8, 2021
If the output comment block of a testable example is not the last
comment block then nothing will be tested. This commit combines the
comment blocks so that the example actually tests against the output.

Fixes cue-lang#1267
Closes cue-lang#1385

Signed-off-by: Amelia Downs <adowns@vmware.com>
Change-Id: I2e1d6f0e6445053988f88ff50249071f40744851
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/528130
Unity-Result: CUEcueckoo <cueckoo@cuelang.org>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Paul Jolly <paul@myitcv.io>
Signed-off-by: Joel Longtine <joel@longtine.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Triage Requires triage/attention
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants