Skip to content

Commit

Permalink
add test cases
Browse files Browse the repository at this point in the history
Signed-off-by: Jade Abraham <[email protected]>
  • Loading branch information
jabraham17 committed Oct 21, 2024
1 parent 8844bed commit 29cd3cc
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test/chplcheck/MissingInIntent.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module MissingInIntent {

record myData {
var x: int;
proc init() {
x = 0;
}
proc init(in d: int) {
x = d;
}
}


record R {
var x: int;
var y: myData;
proc init(newX: int) {
x = newX;
y = new myData();
}
proc init(newY: myData) {
x = 0;
y = newY;
}
@chplcheck.ignore("UnusedFormal")
proc init(newY: myData, dummy: int) {
x = newY.x;
y = new myData();
}
@chplcheck.ignore("UnusedFormal")
proc init(newY: myData, dummy: int, dummy2: int) {
init this;
x = 0;
y = newY;
}
}

}
3 changes: 3 additions & 0 deletions test/chplcheck/MissingInIntent.good
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MissingInIntent.chpl:17: node violates rule MissingInIntent
MissingInIntent.chpl:21: node violates rule MissingInIntent
[Success matching fixit for MissingInIntent]
38 changes: 38 additions & 0 deletions test/chplcheck/MissingInIntent.good-fixit
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module MissingInIntent {

record myData {
var x: int;
proc init() {
x = 0;
}
proc init(in d: int) {
x = d;
}
}


record R {
var x: int;
var y: myData;
proc init(in newX: int) {
x = newX;
y = new myData();
}
proc init(in newY: myData) {
x = 0;
y = newY;
}
@chplcheck.ignore("UnusedFormal")
proc init(newY: myData, dummy: int) {
x = newY.x;
y = new myData();
}
@chplcheck.ignore("UnusedFormal")
proc init(newY: myData, dummy: int, dummy2: int) {
init this;
x = 0;
y = newY;
}
}

}
1 change: 1 addition & 0 deletions test/chplcheck/activerules.good
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Active rules:
IncorrectIndentation Warn for inconsistent or missing indentation
MethodsAfterFields Warn for classes or records that mix field and method definitions.
MisleadingIndentation Warn for single-statement blocks that look like they might be multi-statement blocks.
MissingInIntent Warn for formals used to initialize fields that are missing an 'in' intent.
PascalCaseClasses Warn for classes that are not 'PascalCase'.
PascalCaseModules Warn for modules that are not 'PascalCase'.
SimpleDomainAsRange Warn for simple domains in loops that can be ranges.
Expand Down
1 change: 1 addition & 0 deletions test/chplcheck/allrules.good
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Available rules (default rules marked with *):
* IncorrectIndentation Warn for inconsistent or missing indentation
* MethodsAfterFields Warn for classes or records that mix field and method definitions.
* MisleadingIndentation Warn for single-statement blocks that look like they might be multi-statement blocks.
* MissingInIntent Warn for formals used to initialize fields that are missing an 'in' intent.
NestedCoforalls Warn for nested 'coforall' loops, which could lead to performance hits.
* PascalCaseClasses Warn for classes that are not 'PascalCase'.
* PascalCaseModules Warn for modules that are not 'PascalCase'.
Expand Down

0 comments on commit 29cd3cc

Please sign in to comment.