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

Implemented str * int operations #86

Merged
merged 2 commits into from
Jun 28, 2023
Merged

Implemented str * int operations #86

merged 2 commits into from
Jun 28, 2023

Conversation

nouritsu
Copy link
Contributor

Feature Addition -
str * int will result in a string that is repeated int times
If int is negative or zero, resulting value will be null.

@nouritsu
Copy link
Contributor Author

Question: Where do I add tests? I could not find a test for multiplication and division in the jaq-core/tests/ directory.

However, I have tested the implementation on the command line and it works as expected -

> jaq -n '5 * \"hello\"' 
"hellohellohellohellohello"
> jaq -n '\"hello\" * 5' 
"hellohellohellohellohello"
> jaq -n '\"hello\" * -5'
null
> jaq -n '\"hello\" * 0'
null

This indicates that the commutative property is satisfied and the results obtained are the exact same as on the latest version of jq.

> jq -n '5 * \"hello\"' 
"hellohellohellohellohello"
> jq -n '\"hello\" * 5' 
"hellohellohellohellohello"
> jq -n '\"hello\" * -5'
null
> jq -n '\"hello\" * 0'
null

@nouritsu
Copy link
Contributor Author

nouritsu commented Jun 27, 2023

Tests have been added, this is ready to merge.
#71

@01mf02 01mf02 merged commit 506b985 into 01mf02:main Jun 28, 2023
1 check passed
@01mf02
Copy link
Owner

01mf02 commented Jun 28, 2023

Thanks a lot!

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

2 participants