forked from purpleidea/mgmt
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Gelisam/code rabbit test3 #2
Open
gelisam
wants to merge
16
commits into
master
Choose a base branch
from
gelisam/code-rabbit-test3
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
ca88c80
XXX: newscope iteration with sam. passes! wow
purpleidea 9b83ef1
XXX: wip classes stuff
purpleidea b654a3b
lang: interfaces, parser, ast: Add a bare import constant
purpleidea 1741384
XXX: wip includes stuff
purpleidea 2dd0c16
XXX: class parser changes
purpleidea cf7c2dc
XXX: add new tests for class include as stuff
purpleidea 0add5c2
XXX making some progress on stuff
purpleidea f6ceb97
XXXTESTS
purpleidea 0f1d113
XXX more tests and misc cleanup
purpleidea 18c9522
XXX: wip on ordering and misc
purpleidea 768fe5d
XXX: more including the better??? nodeOrder code
purpleidea 97553b4
XXX more misc hacking
purpleidea dc657e2
XXX don't use the bad ordering code for now...
purpleidea 771175b
XXX fixup some tests
purpleidea 3d795cd
XXX fixup more tests
purpleidea cadcd40
XXX: misc cleanups
purpleidea File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
lang/interpret_test/TestAstFunc2/class-include-as-class0.txtar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
-- main.mcl -- | ||
class c1 { | ||
test "t1" {} | ||
$y = "hello" | ||
class c0 { | ||
test "t2" {} | ||
$x = "goodbye" | ||
} | ||
} | ||
include c1 as i1 # has $y | ||
include i1.c0 as i0 # has $x ...and $y | ||
|
||
test $i0.x {} # ok | ||
test $i0.y {} # sneaky! | ||
test $i1.y {} # ok | ||
panic($i0.x != "goodbye") | ||
panic($i1.y != "hello") | ||
-- OUTPUT -- | ||
Vertex: test[goodbye] | ||
Vertex: test[hello] | ||
Vertex: test[t1] | ||
Vertex: test[t2] |
39 changes: 39 additions & 0 deletions
39
lang/interpret_test/TestAstFunc2/class-include-as-class1.txtar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
-- main.mcl -- | ||
class c1($b) { | ||
test "t1" {} | ||
if $b { | ||
test "t2" {} | ||
} else { | ||
test "t3" {} | ||
} | ||
class c0 { | ||
test "t4" {} | ||
if $b { | ||
test "t5" {} | ||
} else { | ||
test "t6" {} | ||
} | ||
$x = if $b { | ||
"hello" | ||
} else { | ||
"goodbye" | ||
} | ||
} | ||
} | ||
include c1(true) as i1 | ||
include i1.c0 as i01 | ||
|
||
include c1(false) as i2 | ||
include i2.c0 as i02 | ||
|
||
test $i01.x {} | ||
test $i02.x {} | ||
-- OUTPUT -- | ||
Vertex: test[hello] | ||
Vertex: test[goodbye] | ||
Vertex: test[t1] | ||
Vertex: test[t2] | ||
Vertex: test[t3] | ||
Vertex: test[t4] | ||
Vertex: test[t5] | ||
Vertex: test[t6] |
17 changes: 17 additions & 0 deletions
17
lang/interpret_test/TestAstFunc2/class-include-as-class2.txtar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
-- main.mcl -- | ||
class c1($b) { | ||
if $b { # scope doesn't leak up and out of `if` statement! | ||
class inner() { | ||
test "t1" {} | ||
} | ||
} else { | ||
class inner() { | ||
test "t2" {} | ||
} | ||
} | ||
} | ||
|
||
include c1 as i1 | ||
include i1.inner | ||
-- OUTPUT -- | ||
# err: errSetScope: class `c1` expected 1 args but got 0 | ||
11 changes: 11 additions & 0 deletions
11
lang/interpret_test/TestAstFunc2/class-include-as-duplicate0.txtar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-- main.mcl -- | ||
class c1() { | ||
$x = "got: ${s}" | ||
} | ||
|
||
# TODO: can this be allowed? | ||
include c1 as i1 | ||
include c1 as i1 | ||
test $i1.x {} | ||
-- OUTPUT -- | ||
# err: errSetScope: could not generate ordering: duplicate assignment to `scoped:i1`, have: include(c1) |
11 changes: 11 additions & 0 deletions
11
lang/interpret_test/TestAstFunc2/class-include-as-duplicate1.txtar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-- main.mcl -- | ||
class c1($s) { | ||
$x = "got: ${s}" | ||
} | ||
|
||
# TODO: can this be allowed? | ||
include c1("hey") as i1 | ||
include c1("hey") as i1 | ||
test $i1.x {} | ||
-- OUTPUT -- | ||
# err: errSetScope: could not generate ordering: duplicate assignment to `scoped:i1`, have: include(c1) |
10 changes: 10 additions & 0 deletions
10
lang/interpret_test/TestAstFunc2/class-include-as-duplicate2.txtar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
-- main.mcl -- | ||
class c1($s) { | ||
$x = "got: ${s}" | ||
} | ||
|
||
include c1("hey") as i1 | ||
include c1("there") as i1 | ||
test $i1.x {} | ||
-- OUTPUT -- | ||
# err: errSetScope: could not generate ordering: duplicate assignment to `scoped:i1`, have: include(c1) |
14 changes: 14 additions & 0 deletions
14
lang/interpret_test/TestAstFunc2/class-include-as-func-scope0.txtar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
-- main.mcl -- | ||
class c1 { | ||
$x = "outside" | ||
test "t1" {} | ||
func f1($x) { | ||
"hello" + $x | ||
} | ||
} | ||
include c1 as i1 | ||
|
||
test i1.f1("world") {} | ||
-- OUTPUT -- | ||
Vertex: test[helloworld] | ||
Vertex: test[t1] |
14 changes: 14 additions & 0 deletions
14
lang/interpret_test/TestAstFunc2/class-include-as-func-scope1.txtar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
-- main.mcl -- | ||
class c1 { | ||
$x = "world" | ||
test "t1" {} | ||
func f1($y) { | ||
"hello" + $x | ||
} | ||
} | ||
include c1 as i1 | ||
|
||
test i1.f1("whatever") {} | ||
-- OUTPUT -- | ||
Vertex: test[helloworld] | ||
Vertex: test[t1] |
13 changes: 13 additions & 0 deletions
13
lang/interpret_test/TestAstFunc2/class-include-as-func0.txtar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-- main.mcl -- | ||
class c1 { | ||
test "t1" {} | ||
func f1() { | ||
"hello" | ||
} | ||
} | ||
include c1 as i1 | ||
|
||
test i1.f1() {} | ||
-- OUTPUT -- | ||
Vertex: test[hello] | ||
Vertex: test[t1] |
27 changes: 27 additions & 0 deletions
27
lang/interpret_test/TestAstFunc2/class-include-as-func1.txtar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-- main.mcl -- | ||
class c1($b) { | ||
test "t1" {} | ||
if $b { | ||
test "t2" {} | ||
} else { | ||
test "t3" {} | ||
} | ||
func f1() { | ||
if $b { | ||
"hello" | ||
} else { | ||
"goodbye" | ||
} | ||
} | ||
} | ||
include c1(true) as i1 | ||
include c1(false) as i2 | ||
|
||
test i1.f1() {} | ||
test i2.f1() {} | ||
-- OUTPUT -- | ||
Vertex: test[hello] | ||
Vertex: test[goodbye] | ||
Vertex: test[t1] | ||
Vertex: test[t2] | ||
Vertex: test[t3] |
42 changes: 42 additions & 0 deletions
42
lang/interpret_test/TestAstFunc2/class-include-as-func2.txtar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
-- main.mcl -- | ||
class c0($b) { | ||
test "t1" {} | ||
if $b { | ||
test "t2" {} | ||
} else { | ||
test "t3" {} | ||
} | ||
func f0() { | ||
if $b { | ||
"hello" | ||
} else { | ||
"goodbye" | ||
} | ||
} | ||
} | ||
class c1($b) { | ||
test "t4" {} | ||
if $b { | ||
test "t5" {} | ||
} else { | ||
test "t6" {} | ||
} | ||
include c0($b) as i0 | ||
func f1() { i0.f0() } | ||
} | ||
include c1(true) as i1 | ||
include c1(false) as i2 | ||
|
||
test i1.f1() {} | ||
test i2.f1() {} | ||
test i1.i0.f0() {} # I think these might work directly too. Do we want them to? | ||
test i2.i0.f0() {} | ||
-- OUTPUT -- | ||
Vertex: test[goodbye] | ||
Vertex: test[hello] | ||
Vertex: test[t1] | ||
Vertex: test[t2] | ||
Vertex: test[t3] | ||
Vertex: test[t4] | ||
Vertex: test[t5] | ||
Vertex: test[t6] |
10 changes: 10 additions & 0 deletions
10
lang/interpret_test/TestAstFunc2/class-include-as-import1.txtar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
-- main.mcl -- | ||
import "fmt" as i1 | ||
class c1($s) { | ||
$x = fmt.printf("got: %s", $s) | ||
} | ||
|
||
include c1("hey") as i1 | ||
test $i1.x {} | ||
-- OUTPUT -- | ||
# err: errSetScope: could not generate ordering: duplicate assignment to `scoped:i1`, have: import(fmt) |
10 changes: 10 additions & 0 deletions
10
lang/interpret_test/TestAstFunc2/class-include-as-import2.txtar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
-- main.mcl -- | ||
import "fmt" | ||
class c1($s) { | ||
$x = fmt.printf("got: %s", $s) | ||
} | ||
|
||
include c1("hey") as fmt | ||
test $fmt.x {} | ||
-- OUTPUT -- | ||
# err: errSetScope: could not generate ordering: duplicate assignment to `scoped:fmt`, have: import(fmt) |
14 changes: 14 additions & 0 deletions
14
lang/interpret_test/TestAstFunc2/class-include-as-lambda-scope0.txtar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
-- main.mcl -- | ||
class c1 { | ||
$x = "outside" | ||
test "t1" {} | ||
$f1 = func($x) { | ||
"hello" + $x | ||
} | ||
} | ||
include c1 as i1 | ||
|
||
test $i1.f1("world") {} | ||
-- OUTPUT -- | ||
Vertex: test[helloworld] | ||
Vertex: test[t1] |
14 changes: 14 additions & 0 deletions
14
lang/interpret_test/TestAstFunc2/class-include-as-lambda-scope1.txtar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
-- main.mcl -- | ||
class c1 { | ||
$x = "world" | ||
test "t1" {} | ||
$f1 = func($y) { | ||
"hello" + $x | ||
} | ||
} | ||
include c1 as i1 | ||
|
||
test $i1.f1("whatever") {} | ||
-- OUTPUT -- | ||
Vertex: test[helloworld] | ||
Vertex: test[t1] |
13 changes: 13 additions & 0 deletions
13
lang/interpret_test/TestAstFunc2/class-include-as-lambda0.txtar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-- main.mcl -- | ||
class c1 { | ||
test "t1" {} | ||
$f1 = func() { | ||
"hello" | ||
} | ||
} | ||
include c1 as i1 | ||
|
||
test $i1.f1() {} | ||
-- OUTPUT -- | ||
Vertex: test[hello] | ||
Vertex: test[t1] |
27 changes: 27 additions & 0 deletions
27
lang/interpret_test/TestAstFunc2/class-include-as-lambda1.txtar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-- main.mcl -- | ||
class c1($b) { | ||
test "t1" {} | ||
if $b { | ||
test "t2" {} | ||
} else { | ||
test "t3" {} | ||
} | ||
$f1 = func() { | ||
if $b { | ||
"hello" | ||
} else { | ||
"goodbye" | ||
} | ||
} | ||
} | ||
include c1(true) as i1 | ||
include c1(false) as i2 | ||
|
||
test $i1.f1() {} | ||
test $i2.f1() {} | ||
-- OUTPUT -- | ||
Vertex: test[hello] | ||
Vertex: test[goodbye] | ||
Vertex: test[t1] | ||
Vertex: test[t2] | ||
Vertex: test[t3] |
44 changes: 44 additions & 0 deletions
44
lang/interpret_test/TestAstFunc2/class-include-as-lambda2.txtar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
-- main.mcl -- | ||
class c0($b) { | ||
test "t1" {} | ||
if $b { | ||
test "t2" {} | ||
} else { | ||
test "t3" {} | ||
} | ||
$f0 = func() { | ||
if $b { | ||
"hello" | ||
} else { | ||
"goodbye" | ||
} | ||
} | ||
#$f0 = "hey" | ||
} | ||
class c1($b) { | ||
test "t4" {} | ||
if $b { | ||
test "t5" {} | ||
} else { | ||
test "t6" {} | ||
} | ||
include c0($b) as i0 | ||
$x = $i0.f0 | ||
} | ||
include c1(true) as i1 | ||
include c1(false) as i2 | ||
|
||
test $i1.x() {} | ||
test $i1.i0.f0() {} | ||
test $i2.x() {} | ||
test $i1.i0.f0() {} # I think these should work directly too. Do we want them to? | ||
test $i2.i0.f0() {} | ||
-- OUTPUT -- | ||
Vertex: test[goodbye] | ||
Vertex: test[hello] | ||
Vertex: test[t1] | ||
Vertex: test[t2] | ||
Vertex: test[t3] | ||
Vertex: test[t4] | ||
Vertex: test[t5] | ||
Vertex: test[t6] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test file
class-include-as-class2.txtar
demonstrates the error handling for a class include with a conditional block. The output shows the expected error message due to the missing argument in the include statement.Committable suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat that it can find the fix, but too bad that it doesn't realize it's a test which is making sure that "bug" shows up as an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@purpleidea, understood! The test is indeed meant to confirm the correct error handling. I'll take note of this context for future reviews. Thank you for the clarification.
🐰🔍📝
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@coderabbitai Can you tell me anything useful or interesting about the resources in the mcl code? This is a test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@purpleidea, based on the repository's documentation, particularly the
language-guide.md
, here are some insights about theclass
andinclude
statements in the mcl code:include
statement is used to produce output from a class. A class must be 'included' to generate output, and it can be included multiple times with different arguments, allowing for different instantiations.This structure allows for modular and reusable code, where classes can encapsulate functionality and be included as needed, with the flexibility of parameterization to handle different contexts or configurations.
If you need more detailed information or examples, I can look further into the codebase or the documentation.
Analysis chain
Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 6881
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I asked about the resources not the statements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@purpleidea, the term "resources" in the mcl codebase refers to entities that can be defined, managed, and interacted with within the system. They are defined in YAML configurations, controlled through semaphore mechanisms for concurrency, tested for various scenarios, and monitored via Prometheus metrics. Resources are central to the system's operation, representing the managed elements like files, services, packages, and more, each with specific properties and behaviors. They are marshalled into configurations, and their state is managed and observed throughout the system's runtime.
If you need more specific details or examples of resources, please let me know, and I can provide further information.
🐰📘🔍
Analysis chain
Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 45991
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be fair, if I wasn't already familiar with the project, I wouldn't know which lines are resources either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gelisam Yup, I was testing it to see if it was doing anything beyond simple pattern recognition-level stuff =D
I also get the feeling a lot of analysis is based on text docs and comments, which worries me because when do the docs or comments ever match the code 😅