@@ -2,6 +2,15 @@ package pgo
22
33import pgo .model .SourceLocation .UnderlyingFile
44import pgo .parser .TLAParser
5+ import pgo .model .DefinitionOne
6+ import pgo .model .DefinitionComposite
7+ import pgo .model .tla .TLAOperatorDefinition
8+ import pgo .model .tla .TLANumber
9+ import pgo .model .tla .TLANumber .DecimalSyntax
10+ import pgo .model .tla .TLANumber .HexadecimalSyntax
11+ import pgo .model .tla .TLANumber .BinarySyntax
12+ import pgo .model .tla .TLANumber .OctalSyntax
13+ import pgo .model .tla .TLANumber .IntValue
514
615final class TLAUnitCoverageTests extends munit.FunSuite :
716 def checkNames (tlaFile : os.Path , names : List [String ])(using
@@ -32,3 +41,26 @@ final class TLAUnitCoverageTests extends munit.FunSuite:
3241 " Init" ,
3342 ),
3443 )
44+
45+ test(" parsing numbers" ):
46+ val tlaFile = projectRoot / " test" / " files" / " tla" / " Numbers.tla"
47+ val fileContents = os.read(tlaFile)
48+ val underlyingFile = UnderlyingFile (tlaFile)
49+ val module = TLAParser .readModule(underlyingFile, fileContents)
50+
51+ val values = module.units.view
52+ .collect {
53+ case op : TLAOperatorDefinition => op
54+ }.map {
55+ case TLAOperatorDefinition (name, args, body, isLocal) => body
56+ }.collect {
57+ case num : TLANumber => num
58+ }.toList
59+
60+ val expected = List (
61+ TLANumber (IntValue (1 ), DecimalSyntax ),
62+ TLANumber (IntValue (1 ), HexadecimalSyntax ),
63+ TLANumber (IntValue (1 ), BinarySyntax ),
64+ TLANumber (IntValue (1 ), OctalSyntax )
65+ )
66+ assertEquals(values, expected)
0 commit comments