• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

eclipse-aascw / aas-core-codegen / 36298615561

27 Sep 2026 05:55AM UTC coverage: 88.307% (+0.2%) from 88.079%
36298615561

push

github

web-flow
Transpile modulo, negation and abs (#775)

We transpile the modulo operator ``%``, the arithmetic negation (unary
minus) and the built-in ``abs`` in the verification functions and
the invariants for all the targets.

The parse tree gets the nodes ``Mod`` and ``Neg``, while ``abs``
becomes a built-in function next to ``len``. The negation of a numeric
literal is still parsed as a constant. The type inference allows
the modulo only on integers and lengths, and the negation and ``abs``
only on integers and floating-point numbers, since the lengths are
unsigned in C++. The constrained primitives now behave like their
constrainees in the arithmetic operations.

The meta-model is written in Python, where the division is floored
so that the remainder takes the sign of the divisor (``-7 % 3 == 2``).
C#, C++, Go, Java and TypeScript truncate the division instead, so that
their native remainder takes the sign of the dividend
(``-7 % 3 == -1``). The two coincide only when the operands have
the same sign, but the invariants must behave the same in all
the SDKs. Therefore, we do not transpile the modulo to the native
operator. Java uses ``Math.floorMod``, while C#, C++, Go and TypeScript
call a public helper ``FloorMod`` (``floorMod`` in TypeScript) which
we generate in the verification module only if the meta-model uses
the modulo. Go additionally gets ``AbsInt64`` as its standard library
has no integer ``abs``. A native modulo remains only where both
operands are known to be non-negative.

We generate unit tests for the modulo and ``abs`` in all the SDKs from
the cases in the new module ``aas_core_codegen.tests_common``, which
holds the data shared by the generators of unit tests across
the targets. The expected values are computed by Python itself, so that
the clients can look up the behavior and be certain about it.

Along the way, Java now renders the integer literals as ``long``
literals when passed to verification functions, as Java does not
convert an ``in... (continued)

704 of 764 new or added lines in 38 files covered. (92.15%)

1 existing line in 1 file now uncovered.

40086 of 45394 relevant lines covered (88.31%)

2.65 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.07
/aas_core_codegen/java/optional.py


Source Not Available

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc