-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Summary of Changes Add the modulo operator `%`. It follows Python's floor-based implementation and defines `n % d` as $$ n - \left\lfloor\frac{n}{d}\right\rfloor \cdot d $$
- Loading branch information
1 parent
c8f3b67
commit f590e7a
Showing
18 changed files
with
206 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...es/safe-ds-lang/tests/resources/formatting/expressions/arithmetic operators/modulo.sdsdev
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
pipeline myPipeline { | ||
1 % 2; | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
pipeline myPipeline { | ||
1 % 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...hon/expressions/infix operation/generated/tests/generator/infixOperation/gen_input.py.map
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...esources/grammar/expressions/arithmetic operators/bad-modulo without left operator.sdsdev
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// $TEST$ syntax_error | ||
|
||
pipeline myPipeline { | ||
% 2; | ||
} |
5 changes: 5 additions & 0 deletions
5
...sources/grammar/expressions/arithmetic operators/bad-modulo without right operator.sdsdev
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// $TEST$ syntax_error | ||
|
||
pipeline myPipeline { | ||
1 %; | ||
} |
5 changes: 5 additions & 0 deletions
5
.../safe-ds-lang/tests/resources/grammar/expressions/arithmetic operators/good-modulo.sdsdev
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// $TEST$ no_syntax_error | ||
|
||
pipeline myPipeline { | ||
1 % 2; | ||
} |
47 changes: 47 additions & 0 deletions
47
...ng/tests/resources/partial evaluation/recursive cases/infix operations/modulo/main.sdsdev
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package tests.partialValidation.recursiveCases.infixOperations.modulo | ||
|
||
pipeline test { | ||
// $TEST$ serialization 0.25 | ||
»0.25 % 0.5«; | ||
|
||
// $TEST$ serialization 0.5 | ||
»1.5 % 1«; | ||
|
||
// $TEST$ serialization 0.375 | ||
»1 % 0.625«; | ||
|
||
// $TEST$ serialization 0 | ||
»1 % 1«; | ||
|
||
// $TEST$ serialization -1 | ||
»3 % -2«; | ||
|
||
// $TEST$ serialization 1 | ||
»-3 % 2«; | ||
|
||
// $TEST$ serialization -1 | ||
»-3 % -2«; | ||
|
||
|
||
// $TEST$ serialization ? | ||
»1 % 0«; | ||
|
||
// $TEST$ serialization ? | ||
»1 % 0.0«; | ||
|
||
// $TEST$ serialization ? | ||
»1 % -0.0«; | ||
|
||
|
||
// $TEST$ serialization ? | ||
»true % 1«; | ||
|
||
// $TEST$ serialization ? | ||
»1 % true«; | ||
|
||
// $TEST$ serialization ? | ||
»unresolved % 1«; | ||
|
||
// $TEST$ serialization ? | ||
»1 % unresolved«; | ||
} |
Oops, something went wrong.