kcl-lang / kcl

KCL Programming Language (CNCF Sandbox Project). https://kcl-lang.io
https://kcl-lang.io
Apache License 2.0
1.41k stars 110 forks source link

Add test case for if. #1416

Closed liangyuanpeng closed 1 week ago

liangyuanpeng commented 2 weeks ago

Releated https://github.com/kcl-lang/kcl/issues/1410 Add a new test case for if.

1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):

2. What is the scope of this PR (e.g. component or file name):

3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):

4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):

5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:

liangyuanpeng commented 2 weeks ago

It's not clear what the cause of this problem is, but I hope the tests will cover it. cc @He1pa @Peefy PTAL,Thanks.

He1pa commented 2 weeks ago

It's not clear what the cause of this problem is, but I hope the tests will cover it. cc @He1pa @Peefy PTAL,Thanks.

I have found the error. It should be that lazy eval repeatedly executes the if statement when calculating _nodes. Im trying to fix it.

liangyuanpeng commented 2 weeks ago

@He1pa I just noted that https://github.com/kcl-lang/kcl/pull/1418 is merged and then i rebase main here, seems like it's still failing.

Testing /home/runner/work/kcl/kcl/test/grammar/if/if_stmt/test_5
STDOUT:
Condition is true.
Condition is true.
nodes: []

STDERR:
Peefy commented 1 week ago

Hello @liangyuanpeng Fixed in #1418 and #1423.

You can rebase the main branch, and update the test case to

_nodes=[]

if True:
    print("Condition: True") # Use the right YAML form
elif False:
    _nodes+=[]

nodes=_nodes
liangyuanpeng commented 1 week ago

Hi @Peefy Thanks for your quickly reply and work for it!

rebased main.

I have not get that why it's need to use the yaml data, In the real world, this is how people actually use it. Is this due to test case limitations?

--    print("Condition is true.")
++    print("Condition: True") # Use the right YAML form
Peefy commented 1 week ago

Hello @liangyuanpeng

At present, KCL's e2e testing only recognizes legitimate YAML data, which is different from real-world cases.

liangyuanpeng commented 1 week ago

Thank you for your clarification, updated

coveralls commented 1 week ago

Pull Request Test Coverage Report for Build 9594724261

Details


Totals Coverage Status
Change from base Build 9594420056: 0.0%
Covered Lines: 55602
Relevant Lines: 78012

💛 - Coveralls
coveralls commented 1 week ago

Pull Request Test Coverage Report for Build 9594724261

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details


Totals Coverage Status
Change from base Build 9594420056: 0.0%
Covered Lines: 55602
Relevant Lines: 78012

💛 - Coveralls