-
Notifications
You must be signed in to change notification settings - Fork 743
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
Fix issue with global variable as default value for class field and function parameter #40774
Fix issue with global variable as default value for class field and function parameter #40774
Conversation
tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/klass/ClassTest.java
Outdated
Show resolved
Hide resolved
tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/klass/ClassTest.java
Outdated
Show resolved
Hide resolved
tests/jballerina-unit-test/src/test/resources/test-src/klass/simple_class.bal
Outdated
Show resolved
Hide resolved
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #40774 +/- ##
============================================
+ Coverage 76.39% 76.45% +0.05%
- Complexity 52054 52173 +119
============================================
Files 2857 2857
Lines 195858 196066 +208
Branches 25398 25430 +32
============================================
+ Hits 149623 149893 +270
+ Misses 37942 37864 -78
- Partials 8293 8309 +16
☔ View full report in Codecov by Sentry. |
This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the |
This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the |
tests/jballerina-unit-test/src/test/resources/test-src/klass/simple_class.bal
Outdated
Show resolved
Hide resolved
function testModuleVariableReferencingClass() { | ||
ModuleVariableReferencingClass c = new; | ||
assertEquality(c.i, 111222); | ||
assertEquality(c1.i, 111222); | ||
} | ||
|
||
function testLocalObjectConstructorReferencingModuleVariable() { |
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.
Can we make the names uniform? They are both doing the same thing, just different constructs, right?
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.
Updated as testClassReferencingModuleVariable
and testLocalObjectConstructorReferencingModuleVariable
tests/jballerina-unit-test/src/test/resources/test-src/klass/simple_class.bal
Outdated
Show resolved
Hide resolved
BRunUtil.invoke(compileResult, "testModuleVariableReferencingClass"); | ||
} | ||
|
||
@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.
Is this the correct file for this test? Maybe both can go in org.ballerinalang.test.object.ObjectTest
?
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.
Moved to ObjectTest
...allerina-unit-test/src/test/resources/test-src/object/object-referencing-module-variable.bal
Outdated
Show resolved
Hide resolved
...allerina-unit-test/src/test/resources/test-src/object/object-referencing-module-variable.bal
Outdated
Show resolved
Hide resolved
...allerina-unit-test/src/test/resources/test-src/object/object-referencing-module-variable.bal
Outdated
Show resolved
Hide resolved
tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/object/ObjectTest.java
Outdated
Show resolved
Hide resolved
@@ -47,11 +47,14 @@ public class ObjectTest { | |||
|
|||
private CompileResult checkInInitializerResult; | |||
private CompileResult checkFunctionReferencesResult; | |||
private CompileResult checkObjectWithDefaultableFieldsResult; |
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.
Field with default value. Or just object with default values.
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.
change as checkObjectWithDefaultValuesResult
|
||
const ASSERTION_ERROR_REASON = "AssertionError"; | ||
|
||
function assertEquality(any expected, any actual) { |
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.
Why any and not anydata?
@@ -941,6 +942,16 @@ public void testNonPublicSymbolsWarningInServiceClass() { | |||
Assert.assertEquals(result.getDiagnostics().length, 0); | |||
} | |||
|
|||
@Test | |||
public void testClassWithModuleDefaultValue() { |
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.
What does module default value mean?
public void testClassWithModuleDefaultValue() { | |
public void testClassWithModuleLevelVarAsDefaultValue() { |
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.
Updated. I am trying to specify this test case using a module variable as a default value.
tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/object/ObjectTest.java
Outdated
Show resolved
Hide resolved
tests/jballerina-unit-test/src/test/resources/test-src/object/object-with-defaultable-field.bal
Outdated
Show resolved
Hide resolved
const ASSERTION_ERROR_REASON = "AssertionError"; | ||
|
||
function assertEquality(anydata expected, anydata actual) { | ||
if expected is anydata && actual is anydata && expected == actual { |
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.
Don't you get warnings for the checks now? Always true?
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.
Please update the logic, removing unnecessary checks.
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.
didn't get the warning.
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.
Hint rather. Didn't you get unnecessary condition: expression will always evaluate to 'true'
?
Purpose
Fixes #40769
Check List