source: java2python/core/test/testcode/Math.py@ 503

Last change on this file since 503 was 500, checked in by wouter, 17 months ago

#158 fix unary expression translator

File size: 829 bytes
Line 
1from typing import cast
2import sys
3import math
4import random
5from typing import List
6
7
8class Math:
9 # Tests static function calls and references
10 @staticmethod
11 def main(args:List[str]) -> None:
12 # @param args the arguments of the call.
13 sys.stdout.write( ("ok1" if -1.0e0==-1. else "ko1")+'\n')
14 sys.stdout.write( ("ok2" if 1.==1. else "ko2")+'\n')
15 sys.stdout.write( ("ok3" if 1==+1 else "ko3")+'\n')
16 sys.stdout.write( ("ok4" if abs(-1)==1 else "ko4")+'\n')
17 sys.stdout.write( ("ok5" if abs(-1.5)==1.5 else "ko5")+'\n')
18 sys.stdout.write( ("ok6" if math.floor(-1.5)==-2 else "ko6")+'\n')
19 v:float = random.random()
20 sys.stdout.write( ("ok7" if v >= 0 and v <= 1 else "ko7")+'\n')
21 sys.stdout.write( ("ok8" if isinstance((cast(type,1.)),float) else "ko8")+'\n')
22
23if __name__ == "__main__":
24 Math.main(sys.argv[1:])
Note: See TracBrowser for help on using the repository browser.