Skip to content
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

Add test case for if. #1416

Merged
merged 1 commit into from
Jun 20, 2024
Merged

Add test case for if. #1416

merged 1 commit into from
Jun 20, 2024

Conversation

liangyuanpeng
Copy link
Contributor

Releated #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".):

  • N
  • Y

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):

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Other

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

  • N
  • Y

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

  • Unit test
  • Integration test
  • Benchmark (add benchmark stats below)
  • Manual test (add detailed scripts or steps below)
  • Other

@liangyuanpeng
Copy link
Contributor Author

liangyuanpeng commented Jun 17, 2024

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
Copy link
Contributor

He1pa commented Jun 17, 2024

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 liangyuanpeng force-pushed the test_if branch 2 times, most recently from e83babe to 15b1c43 Compare June 19, 2024 05:54
@liangyuanpeng
Copy link
Contributor Author

liangyuanpeng commented Jun 19, 2024

@He1pa I just noted that #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
Copy link
Contributor

Peefy commented Jun 20, 2024

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
Copy link
Contributor Author

liangyuanpeng commented Jun 20, 2024

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
Copy link
Contributor

Peefy commented Jun 20, 2024

Hello @liangyuanpeng

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

@liangyuanpeng
Copy link
Contributor Author

Thank you for your clarification, updated

Signed-off-by: Lan Liang <gcslyp@gmail.com>
Copy link
Contributor

@Peefy Peefy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good Job! LGTM!

Thanks for the contribution!

@coveralls
Copy link
Collaborator

coveralls commented Jun 20, 2024

Pull Request Test Coverage Report for Build 9594724261

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 71.274%

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

💛 - Coveralls

@Peefy Peefy merged commit 9873aaf into kcl-lang:main Jun 20, 2024
9 of 11 checks passed
@coveralls
Copy link
Collaborator

coveralls commented Jun 20, 2024

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

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 71.274%

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

💛 - Coveralls

@liangyuanpeng liangyuanpeng deleted the test_if branch June 21, 2024 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants