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

Implement usage of 'or' on an assignment #1153

Merged
merged 1 commit into from
Dec 6, 2023
Merged

Conversation

luc10921
Copy link
Collaborator

@luc10921 luc10921 commented Dec 1, 2023

Summary or solution description
I couldn't find how this type of operation was called on Python, but this is called a Elvis Operator

How to Reproduce

from boa3.builtin.compile_time import public
@public
def main(param: str) -> str:
other = param or "some default value"
return other

Tests

def test_elvis_operator_str_param(self):
path, _ = self.get_deploy_file_paths('ElvisOperatorStrParam.py')
runner = BoaTestRunner(runner_id=self.method_name())
invokes = []
expected_results = []
invokes.append(runner.call_contract(path, 'main', 'not empty string'))
expected_results.append('not empty string')
invokes.append(runner.call_contract(path, 'main', ''))
expected_results.append('some default value')
runner.execute()
self.assertEqual(VMState.HALT, runner.vm_state, msg=runner.error)
for x in range(len(invokes)):
self.assertEqual(expected_results[x], invokes[x].result)

Platform:

  • OS: Windows 10 x64
  • Python version: Python 3.11

@luc10921 luc10921 self-assigned this Dec 1, 2023
@lllwvlvwlll
Copy link
Member

@coveralls
Copy link
Collaborator

Coverage Status

coverage: 92.026% (-0.04%) from 92.069%
when pulling 706f6c1 on CU-864e5k912
into 1d4cb9b on development.

@meevee98 meevee98 merged commit f11e567 into development Dec 6, 2023
3 checks passed
@meevee98 meevee98 deleted the CU-864e5k912 branch December 6, 2023 17:55
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.

None yet

4 participants