Skip to content

Commit

Permalink
test: add tests for scoping of arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-reimann committed Oct 5, 2023
1 parent 8d68a42 commit b2cc2e4
Show file tree
Hide file tree
Showing 11 changed files with 268 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/resources/scoping/arguments/of annotation calls/main.sdstest
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package tests.scoping.arguments.ofAnnotationCalls

annotation MyAnnotation(
// $TEST$ target a
»a«: Int,
// $TEST$ target b
»b«: Int = 0,
// $TEST$ target c
vararg »c«: Int
)

@MyAnnotation(
// $TEST$ references c
»c« = 0,
// $TEST$ references a
»a« = 0,
// $TEST$ references b
»b« = 0
)
pipeline myPipeline {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package tests.scoping.arguments.ofCalls.toParameterOfAnnotation

annotation MyAnnotation(
// $TEST$ target a
»a«: Int,
// $TEST$ target b
»b«: Int = 0,
// $TEST$ target c
vararg »c«: Int
)

pipeline myPipeline {
MyAnnotation(
// $TEST$ references c
»c« = 0,
// $TEST$ references a
»a« = 0,
// $TEST$ references b
»b« = 0
);

val alias = MyAnnotation;
alias(
// $TEST$ references c
»c« = 0,
// $TEST$ references a
»a« = 0,
// $TEST$ references b
»b« = 0
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package tests.scoping.arguments.ofCalls.toParameterOfBlockLambda

pipeline myPipeline {
val myBlockLambda = (
// $TEST$ target a
»a«: Int,
// $TEST$ target b
»b«: Int = 0,
// $TEST$ target c
vararg »c«: Int
) {};

myBlockLambda(
// $TEST$ references c
»c« = 0,
// $TEST$ references a
»a« = 0,
// $TEST$ references b
»b« = 0
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package tests.scoping.arguments.ofCalls.toParameterOfCallableType

segment mySegment(myCallableType: (
// $TEST$ target a
»a«: Int,
// $TEST$ target b
»b«: Int = 0,
// $TEST$ target c
vararg »c«: Int
) -> ()) {
myCallableType(
// $TEST$ references c
»c« = 0,
// $TEST$ references a
»a« = 0,
// $TEST$ references b
»b« = 0
);

val alias = myCallableType;
alias(
// $TEST$ references c
»c« = 0,
// $TEST$ references a
»a« = 0,
// $TEST$ references b
»b« = 0
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package tests.scoping.arguments.ofCalls.toParameterOfClass

class MyClass(
// $TEST$ target a
»a«: Int,
// $TEST$ target b
»b«: Int = 0,
// $TEST$ target c
vararg »c«: Int
) {}

pipeline myPipeline {
MyClass(
// $TEST$ references c
»c« = 0,
// $TEST$ references a
»a« = 0,
// $TEST$ references b
»b« = 0
);

val alias = MyClass;
alias(
// $TEST$ references c
»c« = 0,
// $TEST$ references a
»a« = 0,
// $TEST$ references b
»b« = 0
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package tests.scoping.arguments.ofCalls.toParameterOfEnumVariant

enum MyEnum {
MyEnumVariant(
// $TEST$ target a
»a«: Int,
// $TEST$ target b
»b«: Int = 0,
// $TEST$ target c
vararg »c«: Int
)
}


pipeline myPipeline {
MyEnum.MyEnumVariant(
// $TEST$ references c
»c« = 0,
// $TEST$ references a
»a« = 0,
// $TEST$ references b
»b« = 0
);

val alias = MyEnum.MyEnumVariant;
alias(
// $TEST$ references c
»c« = 0,
// $TEST$ references a
»a« = 0,
// $TEST$ references b
»b« = 0
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package tests.scoping.arguments.ofCalls.toParameterOfExpressionLambda

pipeline myPipeline {
val myExpressionLambda = (
// $TEST$ target a
»a«: Int,
// $TEST$ target b
»b«: Int = 0,
// $TEST$ target c
vararg »c«: Int
) -> 1;

myExpressionLambda(
// $TEST$ references c
»c« = 0,
// $TEST$ references a
»a« = 0,
// $TEST$ references b
»b« = 0
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package tests.scoping.arguments.ofCalls.toParameterOfFunction

fun myFunction(
// $TEST$ target a
»a«: Int,
// $TEST$ target b
»b«: Int = 0,
// $TEST$ target c
vararg »c«: Int
)

pipeline myPipeline {
myFunction(
// $TEST$ references c
»c« = 0,
// $TEST$ references a
»a« = 0,
// $TEST$ references b
»b« = 0
);

val alias = myFunction;
alias(
// $TEST$ references c
»c« = 0,
// $TEST$ references a
»a« = 0,
// $TEST$ references b
»b« = 0
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package tests.scoping.arguments.ofCalls.toParameterOfSegment

segment mySegment(
// $TEST$ target a
»a«: Int,
// $TEST$ target b
»b«: Int = 0,
// $TEST$ target c
vararg »c«: Int
) {}

pipeline myPipeline {
mySegment(
// $TEST$ references c
»c« = 0,
// $TEST$ references a
»a« = 0,
// $TEST$ references b
»b« = 0
);

val alias = mySegment;
alias(
// $TEST$ references c
»c« = 0,
// $TEST$ references a
»a« = 0,
// $TEST$ references b
»b« = 0
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package tests.scoping.arguments.ofCalls.toSomethingOtherThanParameter

fun f(a: Int)

pipeline myPipeline {
// $TEST$ unresolved
f(»f« = 1);
}
11 changes: 11 additions & 0 deletions tests/resources/scoping/arguments/of calls/unresolved/main.sdstest
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package tests.scoping.arguments.ofCalls.unresolved

fun f(a: Int)

pipeline myPipeline {
// $TEST$ unresolved
f(»unresolved« = 1);

// $TEST$ unresolved
unresolved(»a« = 1);
}

0 comments on commit b2cc2e4

Please sign in to comment.