DIRECTORY Convert, EditedStream, FS, IO, IOClasses, RefText, Rope, ViewerIO; IOTestImpl: PROGRAM IMPORTS Convert, EditedStream, FS, IO, IOClasses, RefText, Rope, ViewerIO = BEGIN ROPE: TYPE = Rope.ROPE; STREAM: TYPE = IO.STREAM; Value: TYPE = IO.Value; TokenKind: TYPE = IO.TokenKind; TokenError: TYPE = IO.TokenError; AssertionFailed: SIGNAL = CODE; TestFailed: ERROR = CODE; Copy: PROC [in, out: STREAM] = { DO out.PutChar[in.GetChar[! IO.EndOfStream => EXIT]]; ENDLOOP; }; Assert: PROC [condition: BOOL] = { IF condition THEN RETURN; SIGNAL AssertionFailed; -- go to debugger ERROR TestFailed; -- return to test loop }; AssertEqualRopes: PROC [r1, r2: ROPE] = { Assert[Rope.Equal[r1, r2]]; }; AssertRopeEqualInputStream: PROC [r: ROPE, s: STREAM] = { l: INT = r.Length[]; FOR i: INT _ 0, i+1 UNTIL i = l DO Assert[NOT s.EndOf[]]; Assert[s.GetChar[] = r.Fetch[i]]; ENDLOOP; THROUGH [0 .. 10] DO Assert[s.EndOf[]]; [] _ s.GetChar[ ! IO.EndOfStream => LOOP]; Assert[FALSE]; ENDLOOP; }; AssertEqualRopeLists: PROC [l1, l2: LIST OF ROPE] = { DO IF l1 = NIL THEN { Assert[l2 = NIL]; RETURN }; Assert[Rope.Equal[l1.first, l2.first]]; l1 _ l1.rest; l2 _ l2.rest; ENDLOOP }; TestLoop: PROC [] = { TestSimpleStreams[]; TestEditedStreams[]; TestIOClasses[]; TestPrint[]; TestScan[]; TestConvert[]; }; TestSimpleStreams: PROC [] = { TestNullStreams[ ! TestFailed => CONTINUE]; TestRIS[ ! TestFailed => CONTINUE]; TestROS[ ! TestFailed => CONTINUE]; TestTIS[ ! TestFailed => CONTINUE]; TestTOS[ ! TestFailed => CONTINUE]; }; TestNullStreams: PROC [] = { s: STREAM; chars: PACKED ARRAY [0 .. 10) OF CHAR; charsPtr: LONG POINTER TO PACKED ARRAY [0 .. 10) OF CHAR = @chars; out.PutRope["TestNullStreams started\n"]; s _ IO.noWhereStream; Assert[s.GetInfo[].variety = $output]; Assert[s.GetInfo[].class = $Null]; s.Close[]; s.Reset[]; s.PutChar['a]; s.PutBlock["bcd"]; s.UnsafePutBlock[block: [LOOPHOLE[charsPtr], 0, 10]]; s.Flush[]; s.EraseChar['a]; s _ IO.noInputStream; Assert[s.GetInfo[].variety = $input]; Assert[s.GetInfo[].class = $Null]; s.Close[]; s.Reset[]; Assert[s.EndOf[]]; Assert[s.CharsAvail[] > 0]; { [] _ s.GetChar[ ! IO.EndOfStream => GOTO ok]; Assert[FALSE]; EXITS ok => NULL }; { s.Backup['a ! IO.Error => IF ec = $IllegalBackup THEN GOTO ok ELSE CONTINUE]; Assert[FALSE]; EXITS ok => NULL }; Assert[s.GetBlock[RefText.New[10]] = 0]; Assert[s.UnsafeGetBlock[block: [LOOPHOLE[charsPtr], 0, 10]] = 0]; out.PutRope["TestNullStreams ended\n"]; }; TestRIS: PROC [] = { s: STREAM; r: ROPE = "This is a rope"; out.PutRope["TestRIS started\n"]; s _ IO.RIS[r]; Assert[s.GetInfo[].variety = $input]; Assert[s.GetInfo[].class = $ROPE]; s.Backup[s.GetChar[]]; Assert[s.GetIndex[] = 0]; Assert[s.GetLength[] = r.Length[]]; s.Reset[]; Assert[s.EndOf[]]; s.Close[]; s _ IO.RIS[r]; AssertRopeEqualInputStream[r, s]; s.Close[]; s _ IO.RIS[r, s]; AssertRopeEqualInputStream[r, s]; s.Close[]; out.PutRope["TestRIS ended\n"]; }; TestTIS: PROC [] = { s: STREAM; t: REF TEXT = "This is a ref text"; r: ROPE = "This is a ref text"; out.PutRope["TestTIS started\n"]; s _ IO.TIS[t]; Assert[s.GetInfo[].variety = $input]; Assert[s.GetInfo[].class = $TEXT]; s.Backup[s.GetChar[]]; Assert[s.GetIndex[] = 0]; Assert[s.GetLength[] = t.length]; s.Reset[]; Assert[s.EndOf[]]; s.Close[]; s _ IO.TIS[t]; AssertRopeEqualInputStream[r, s]; s.Close[]; s _ IO.TIS[t, s]; AssertRopeEqualInputStream[r, s]; s.Close[]; out.PutRope["TestTIS ended\n"]; }; TestROS: PROC [] = { s: STREAM; r0: ROPE = "This is a rope\n"; r1: ROPE = "This is another rope"; out.PutRope["TestROS started\n"]; s _ IO.ROS[]; Assert[s.GetInfo[].variety = $output]; Assert[s.GetInfo[].class = $ROPE]; s.PutRope[r0]; s.PutChar['a]; s.EraseChar['a]; s.Flush[]; AssertEqualRopes[r0, s.RopeFromROS[]]; s _ IO.ROS[s]; s.PutRope[r0]; AssertEqualRopes[r0, s.RopeFromROS[close: FALSE]]; s.PutRope[r1]; AssertEqualRopes[Rope.Cat[r0, r1], s.RopeFromROS[]]; out.PutRope["TestROS ended\n"]; }; TestTOS: PROC [] = { s: STREAM; r0: ROPE = "This is a rope\n"; r1: ROPE = "This is another rope"; out.PutRope["TestTOS started\n"]; s _ IO.TOS[]; Assert[s.GetInfo[].variety = $output]; Assert[s.GetInfo[].class = $TEXT]; s.PutRope[r0]; s.PutChar['a]; s.EraseChar['a]; s.Flush[]; AssertEqualRopes[r0, RefText.TrustTextAsRope[s.TextFromTOS[]]]; s _ IO.TOS[NIL, s]; s.PutRope[r0]; AssertEqualRopes[r0, RefText.TrustTextAsRope[s.TextFromTOS[]]]; s.PutRope[r1]; AssertEqualRopes[Rope.Cat[r0, r1], RefText.TrustTextAsRope[s.TextFromTOS[]]]; out.PutRope["TestTOS ended\n"]; }; TestEditedStreams: PROC [] = { out.PutRope["TestEditedStreams started\n"]; TestOneEditedStream[ inChars: "\n", expectedEchoChars: "\n", expectedDeliveredChars: "\n", deliverWhen: EditedStream.IsACR]; TestOneEditedStream[ inChars: "This is a test\nIt is only a testx\001 word\027\001\nline of words\021\n", expectedEchoChars: "This is a test\nIt is only a test\n\n", expectedDeliveredChars: "This is a test\nIt is only a test\n\n", deliverWhen: EditedStream.IsACR]; TestOneEditedStream[ inChars: "This is a line\n\033\027\001nother line\n", expectedEchoChars: "This is a line\nThis is another line\n", expectedDeliveredChars: "This is a line\nThis is another line\n", deliverWhen: EditedStream.IsACR]; TestOneEditedStream[ inChars: "This is a line\nESC\033 is a noop here\n", expectedEchoChars: "This is a line\nESC is a noop here\n", expectedDeliveredChars: "This is a line\nESC is a noop here\n", deliverWhen: EditedStream.IsACR]; out.PutRope["TestEditedStreams ended\n"]; }; TestOneEditedStream: PROC [inChars, expectedEchoChars, expectedDeliveredChars: ROPE, deliverWhen: EditedStream.DeliverWhenProc] = { in: STREAM = IO.RIS[inChars]; echo: STREAM = IO.ROS[]; saveDelivered: STREAM = IO.ROS[]; editedStream: STREAM = EditedStream.Create[in: in, echoTo: echo, deliverWhen: deliverWhen]; Copy[in: editedStream, out: saveDelivered]; AssertEqualRopes[expectedEchoChars, echo.RopeFromROS[]]; AssertEqualRopes[expectedDeliveredChars, saveDelivered.RopeFromROS[]]; }; TestIOClasses: PROC [] = { out.PutRope["TestIOClasses started\n"]; TestOneFilterCommentStream[ inChars: "Foo: PROGRAM --\n=----{-- --}.", expectedDeliveredChars: "Foo: PROGRAM \n= { }."]; TestDribbleOutputStream[]; out.PutRope["TestIOClasses ended\n"]; }; TestOneFilterCommentStream: PROC [inChars, expectedDeliveredChars: ROPE] = { in: STREAM = IO.RIS[inChars]; saveDelivered: STREAM = IO.ROS[]; filteredStream: STREAM = IOClasses.CreateCommentFilterStream[input: in]; Copy[in: filteredStream, out: saveDelivered]; AssertEqualRopes[expectedDeliveredChars, saveDelivered.RopeFromROS[]]; }; TestDribbleOutputStream: PROC [] = TRUSTED { chars: PACKED ARRAY [0 .. 4) OF CHAR _ ['T, 'h, 'i, 's]; charsPtr: LONG POINTER TO PACKED ARRAY [0 .. 4) OF CHAR = @chars; out1: STREAM = IO.ROS[]; out2: STREAM = IO.ROS[]; dribble: STREAM = IOClasses.CreateDribbleOutputStream[out1, out2]; dribble.PutChar['T]; dribble.PutBlock[block: "his is a test\n"]; dribble.UnsafePutBlock[block: [LOOPHOLE[charsPtr], 0, 4]]; dribble.Flush[]; dribble.PutRope[" is only a test\n\n"]; dribble.EraseChar['\n]; AssertEqualRopes["This is a test\nThis is only a test\n", out1.RopeFromROS[close: FALSE]]; AssertEqualRopes["This is a test\nThis is only a test\n", out2.RopeFromROS[close: FALSE]]; dribble.Reset[]; dribble.Close[]; }; TestPrint: PROC [] = { TestPut[ ! TestFailed => CONTINUE]; TestPutF[ ! TestFailed => CONTINUE]; }; TestPut: PROC [] = { s: STREAM; out.PutRope["TestPut started\n"]; s _ IO.ROS[]; s.Put[IO.int[0], IO.card[0], IO.char['0]]; s.Put[IO.rope["0"], IO.text["0"]]; s.Put[IO.atom[NIL], IO.atom[$NIL]]; s.Put[IO.bool[TRUE], IO.bool[FALSE]]; s.PutL[LIST[IO.real[1234.43E-1], IO.char[' ], IO.card[123456543]]]; AssertEqualRopes[s.RopeFromROS[], "00000NILTRUEFALSE123.443 123456543"]; out.PutRope["TestPut ended\n"]; }; TestPutF: PROC = { TestFormat: PROC [result, format: ROPE _ NIL, v: Value] = { ENABLE TestFailed => CONTINUE; stream: STREAM = IO.ROS[]; stream.PutF[format, v]; AssertEqualRopes[stream.RopeFromROS[], result]; }; out.PutRope["TestPutF started\n"]; TestFormat["|atom|", "|%g|", IO.atom[$atom]]; TestFormat["| atom|", "|%7g|", IO.atom[$atom]]; TestFormat["|atom |", "|%-7g|", IO.atom[$atom]]; TestFormat["|123|", "|%d|", IO.card[123]]; TestFormat["|123|", "|%g|", IO.card[123]]; TestFormat["| 123|", "|%5g|", IO.card[123]]; TestFormat["| 123|", "|%5d|", IO.card[123]]; TestFormat["|00123|", "|%05d|", IO.card[123]]; TestFormat["|123 |", "|%-5d|", IO.card[123]]; TestFormat["|1234567|", "|%5d|", IO.card[1234567]]; TestFormat["| 10B|", "|%4b|", IO.card[8]]; TestFormat["| 1FH|", "|%4x|", IO.card[31]]; TestFormat["|1.234532e+4|", "|%4.5e|", IO.real[12345.321]]; TestFormat["| 12:00:01|", "|%9r|", IO.int[43201]]; out.PutRope["TestPutF ended\n"]; }; TestScan: PROC [] = { TestGetToken[ ! TestFailed => CONTINUE]; TestGetLine[ ! TestFailed => CONTINUE]; TestSkipOver[ ! TestFailed => CONTINUE]; TestGetCedarToken[ ! TestFailed => CONTINUE]; CheckFileForErrors["IOTestImpl.mesa" ! TestFailed => CONTINUE]; }; TestGetToken: PROC [] = { GetTokenize: PROC [s: STREAM, break: IO.BreakProc] RETURNS [LIST OF ROPE] = { l: LIST OF ROPE _ CONS[NIL, NIL]; lTail: LIST OF ROPE _ l; DO lTail.rest _ CONS[first: s.GetTokenRope[break ! IO.EndOfStream => EXIT].token, rest: NIL]; lTail _ lTail.rest; ENDLOOP; RETURN [l.rest] }; OneGetTokenTest: PROC [r: ROPE, l: LIST OF ROPE, break: IO.BreakProc _ IO.TokenProc] = { AssertEqualRopeLists[GetTokenize[IO.RIS[r], break], l]; }; out.PutRope["TestGetToken started\n"]; OneGetTokenTest["123abc 456def/ +- ", LIST["123abc", "456def", "/", "+", "-"]]; OneGetTokenTest["123abc 456def/ +-", LIST["123abc", "456def", "/", "+", "-"]]; out.PutRope["TestGetToken ended\n"]; }; TestGetLine: PROC [] = { GetLineize: PROC [s: STREAM] RETURNS [LIST OF ROPE] = { l: LIST OF ROPE _ CONS[NIL, NIL]; lTail: LIST OF ROPE _ l; DO lTail.rest _ CONS[first: s.GetLineRope[ ! IO.EndOfStream => EXIT], rest: NIL]; lTail _ lTail.rest; ENDLOOP; RETURN [l.rest] }; OneGetLineTest: PROC [r: ROPE, l: LIST OF ROPE] = { AssertEqualRopeLists[GetLineize[IO.RIS[r]], l]; }; out.PutRope["TestGetLine started\n"]; OneGetLineTest["123abc\n456def\n\n", LIST["123abc", "456def", ""]]; OneGetLineTest["123abc\n456def\n\n ", LIST["123abc", "456def", "", " "]]; out.PutRope["TestGetLine ended\n"]; }; TestSkipOver: PROC [] = { }; TestGetCedarToken: PROC [] = { GetCedarTokenize: PROC [s: STREAM, flushComments: BOOL] RETURNS [LIST OF TokenKind, LIST OF ROPE] = { t: LIST OF TokenKind _ CONS[tokenEOF, NIL]; tTail: LIST OF TokenKind _ t; l: LIST OF ROPE _ CONS[NIL, NIL]; lTail: LIST OF ROPE _ l; tokenKind: TokenKind; token: ROPE; DO [tokenKind: tokenKind, token: token] _ s.GetCedarTokenRope[flushComments ! IO.EndOfStream => EXIT]; tTail.rest _ CONS[tokenKind, NIL]; tTail _ tTail.rest; lTail.rest _ CONS[token, NIL]; lTail _ lTail.rest; ENDLOOP; RETURN [t.rest, l.rest] }; OneGetCedarTokenTest: PROC [ r: ROPE, t: LIST OF TokenKind, l: LIST OF ROPE, flushComments: BOOL] = { t1: LIST OF TokenKind; l1: LIST OF ROPE; [t1, l1] _ GetCedarTokenize[IO.RIS[r], flushComments]; AssertEqualTokenKindLists[t, t1]; AssertEqualRopeLists[l, l1]; }; AssertEqualTokenKindLists: PROC [l1, l2: LIST OF TokenKind] = { DO IF l1 = NIL THEN { Assert[l2 = NIL]; RETURN }; Assert[l1.first = l2.first]; l1 _ l1.rest; l2 _ l2.rest; ENDLOOP }; out.PutRope["TestGetCedarToken started\n"]; OneGetCedarTokenTest[ "ab+cd--ef\n--gh-- ", LIST[$tokenID, $tokenSINGLE, $tokenID], LIST["ab", "+", "cd"], TRUE]; OneGetCedarTokenTest[ "ab+cd--ef\n--gh--", LIST[$tokenID, $tokenSINGLE, $tokenID, $tokenCOMMENT, tokenCOMMENT], LIST["ab", "+", "cd", "--ef\n", "--gh--"], FALSE]; out.PutRope["TestGetCedarToken ended\n"]; }; CheckFileForErrors: PROC [file: ROPE] = { stream: IO.STREAM; scratch: REF TEXT; token: REF TEXT; tokenKind: TokenKind; out.PutRope["CheckFileForErrors started..."]; stream _ FS.StreamOpen[file ! FS.Error => { out.PutRope[error.explanation]; out.PutChar['\n]; RETRY }]; out.PutRope["Stream open\n"]; scratch _ RefText.ObtainScratch[100]; DO [tokenKind: tokenKind, token: token] _ stream.GetCedarToken[scratch]; Assert[tokenKind # tokenERROR]; IF tokenKind = tokenEOF THEN EXIT; IF token # scratch THEN { out.PutRope["Token more than 100 bytes long\n"]; out.PutText[token]; }; ENDLOOP; RefText.ReleaseScratch[scratch]; stream.Close[]; out.PutRope["CheckFileForErrors ended\n"]; }; TestConvert: PROC [] = { TestConversions[ ! TestFailed => CONTINUE]; TestParses[ ! TestFailed => CONTINUE]; }; TestConversions: PROC = { out.PutRope["TestConversions started\n"]; TestIntFromRope["0", 0]; TestIntFromRope["000", 000]; TestIntFromRope["12343", 12343]; TestIntFromRope["8D", 8D]; TestIntFromRope["8D2", 8D2]; TestIntFromRope["+8D2", +8D2]; TestIntFromRope["-8D2", -8D2]; TestIntFromRope[" -8D2 ", -8D2]; TestIntFromRope["2147483647", INT.LAST]; TestIntFromRope["-2147483648", INT.FIRST]; TestIntFromRope["2D09", 2D09]; TestIntFromRope["377B", 377B]; TestIntFromRope["-377B", -377B]; TestIntFromRope["-377B2", -377B2]; TestIntFromRope["17777777777B", 17777777777B]; TestIntFromRope["1777777777B1", 1777777777B1]; TestIntFromRope["1B10", 1B10]; TestIntFromRope["0FFH", 0FFH]; TestIntFromRope["-0FFH", -0FFH]; TestIntFromRope["-0100H2", -0100H2]; -- -0FFH2 overflows (in compiler) TestIntFromRope["7FFFFFFFH", 7FFFFFFFH]; TestIntFromRope["7FFFFFFH1", 7FFFFFFH1]; TestIntFromRope["7H7", 7H7]; TestIntFromRope["", 0, TRUE]; TestIntFromRope[" ", 0, TRUE]; TestIntFromRope["/", 0, TRUE]; TestIntFromRope["-8D-2", 0, TRUE]; TestIntFromRope["-8D2D2", 0, TRUE]; TestIntFromRope["2D10", 0, TRUE]; TestIntFromRope["2147483648", 0, TRUE]; TestIntFromRope["-2147483649", 0, TRUE]; TestIntFromRope["-8B-2", 0, TRUE]; TestIntFromRope["-8B2B2", 0, TRUE]; TestIntFromRope["2B10", 0, TRUE]; TestIntFromRope["40000000000B", 0, TRUE]; TestIntFromRope["4B10", 0, TRUE]; TestIntFromRope["-8H-2", 0, TRUE]; TestIntFromRope["100000000H", 0, TRUE]; TestIntFromRope["1H8", 0, TRUE]; TestRealFromRope["99999999999999999999.0", 1.0E+20]; TestRealFromRope["0.99999999999999999999", 1.0]; TestRealFromRope["99999999999999999999.99999999999999999999", 1.0E+20]; TestRealFromRope[".0", .0]; TestRealFromRope["1E0", 1.0]; TestRealFromRope["1E+0", 1.0]; TestRealFromRope["1E-0", 1.0]; TestRealFromRope["1.", 1.0, TRUE]; TestRealFromRope[".E", 1.0, TRUE]; TestRealFromRope["1E", 1.0, TRUE]; TestRealFromRope["1.E0", 1.0, TRUE]; out.PutRope["TestConversions ended\n"]; }; TestIntFromRope: PROC [r: ROPE, i: INT, fail: BOOL _ FALSE] = { ENABLE TestFailed => CONTINUE; ri: INT _ Convert.IntFromRope[r ! Convert.Error => { Assert[fail]; GOTO return }]; Assert[NOT fail AND (ri = i)]; EXITS return => NULL }; TestRealFromRope: PROC [r: ROPE, e: REAL, fail: BOOL _ FALSE] = { ENABLE TestFailed => CONTINUE; rr: REAL _ Convert.RealFromRope[r ! Convert.Error => { Assert[fail]; GOTO return }]; Assert[NOT fail AND (rr = e)]; EXITS return => NULL }; TestParses: PROC = { out.PutRope["TestParses started\n"]; TestParse["\"error extended char in rope \\", IO.rope[NIL], TRUE]; TestParse["\"error extended char in rope \\x", IO.rope[NIL], TRUE]; TestParse["\"error extended char in rope \\1x", IO.rope[NIL], TRUE]; TestParse["\"error extended char in rope \\12x", IO.rope[NIL], TRUE]; TestParse["\"error extended char in rope \\12c", IO.rope[NIL], TRUE]; TestParse["\"error extended char in rope \\777", IO.rope[NIL], TRUE]; TestParse["\"error extended char in rope \\999", IO.rope[NIL], TRUE]; TestParse["\"ok extended char in rope \\n\"", IO.rope["ok extended char in rope \n"]]; TestParse["\"ok extended char in rope \\277\"", IO.rope["ok extended char in rope \277"]]; TestParse["'\\", IO.char[0C], TRUE]; TestParse["'\\x", IO.char[0C], TRUE]; TestParse["'\\1", IO.char[0C], TRUE]; TestParse["'\\12", IO.char[0C], TRUE]; TestParse["'\\12c", IO.char[0C], TRUE]; TestParse["'\\777", IO.char[0C], TRUE]; TestParse["'\\999", IO.char[0C], TRUE]; TestParse["'\\n", IO.char['\n]]; TestParse["'\\277", IO.char['\277]]; TestParse["\"funny rope literal \\015 \\n\"\" .\"", IO.rope["funny rope literal \015 \n\" ."]]; TestParse["\"unterminated rope literal ...", IO.rope[NIL], TRUE]; TestParse["$atom", IO.atom[$atom]]; TestParse["$", IO.atom[$NIL], TRUE]; TestParse["$1234", IO.atom[$NIL], TRUE, TRUE]; TestParse["1234.43E-1", IO.real[1234.43E-1]]; TestParse[".12343", IO.real[.12343]]; TestParse["5E5", IO.real[5E5]]; TestParse["5E+5", IO.real[5E+5]]; TestParse["5E-5", IO.real[5E-5]]; TestParse["015C", IO.char[015C]]; TestParse["'c", IO.char['c]]; TestParse["'\\t", IO.char['\t]]; TestParse["'\\015", IO.char['\015]]; TestParse["12343", IO.card[12343]]; TestParse["0A0H", IO.card[0A0H]]; TestParse["10B", IO.card[10B]]; TestParse["8B", IO.card[0], TRUE]; TestParse["8D2", IO.card[8D2]]; TestParse["08D02", IO.card[08D02]]; TestParse["TRUE", IO.bool[TRUE]]; TestParse["N", IO.bool[FALSE]]; out.PutRope["TestParses ended\n"]; }; TestParse: PROC [rope: Rope.ROPE, value: Value, error: BOOLEAN _ FALSE, streamNonempty: BOOL _ FALSE] = { ENABLE TestFailed => CONTINUE; AssertL: PROC [condition: BOOL] = { IF condition OR error THEN RETURN; SIGNAL AssertionFailed; -- go to debugger ERROR TestFailed; -- return to test loop }; stream: STREAM _ IO.RIS[rope]; tokenRope: ROPE; scratch: REF TEXT = RefText.ObtainScratch[100]; token: REF TEXT; errorMsg: TokenError; tokenKind: TokenKind; { -- EXITS TestEOF ENABLE Convert.Error => { AssertL[FALSE]; GOTO TestEOF }; [tokenKind, token, , errorMsg] _ stream.GetCedarToken[scratch]; tokenRope _ RefText.TrustTextAsRope[token]; SELECT tokenKind FROM tokenID => WITH value SELECT FROM rope: Value.rope => AssertL[tokenRope.Equal[rope.value]]; bool: Value.boolean => { b: BOOL = Convert.BoolFromRope[tokenRope]; AssertL[b = bool.value] }; ENDCASE => AssertL[FALSE]; tokenDECIMAL => WITH value SELECT FROM card: Value.cardinal => { c: LONG CARDINAL = Convert.CardFromDecimalLiteral[tokenRope]; AssertL[c = card.value] }; ENDCASE => AssertL[FALSE]; tokenOCTAL => WITH value SELECT FROM card: Value.cardinal => { c: LONG CARDINAL = Convert.CardFromOctalLiteral[tokenRope]; AssertL[c = card.value] }; ENDCASE => AssertL[FALSE]; tokenHEX => WITH value SELECT FROM card: Value.cardinal => { c: LONG CARDINAL = Convert.CardFromHexLiteral[tokenRope]; AssertL[c = card.value] }; ENDCASE => AssertL[FALSE]; tokenREAL => WITH value SELECT FROM real: Value.real => { r: REAL = Convert.RealFromRope[tokenRope]; AssertL[r = real.value] }; ENDCASE => AssertL[FALSE]; tokenCHAR => WITH value SELECT FROM char: Value.character => { c: CHAR = Convert.CharFromLiteral[tokenRope]; AssertL[c = char.value] }; ENDCASE => AssertL[FALSE]; tokenROPE => WITH value SELECT FROM -- tokenRope => a rope literal rope: Value.rope => { r: ROPE = Convert.RopeFromLiteral[tokenRope]; AssertL[r.Equal[rope.value]] }; ENDCASE => AssertL[FALSE]; tokenATOM => WITH value SELECT FROM atom: Value.atom => { a: ATOM = Convert.AtomFromRope[tokenRope]; AssertL[a = atom.value] }; ENDCASE => AssertL[FALSE]; ENDCASE => AssertL[FALSE]; GOTO TestEOF; EXITS TestEOF => { [tokenKind, token, , errorMsg] _ stream.GetCedarToken[scratch]; SELECT tokenKind FROM tokenEOF => Assert[NOT streamNonempty]; ENDCASE => Assert[streamNonempty]; RefText.ReleaseScratch[scratch] }; }}; in, out: STREAM; [in: in, out: out] _ ViewerIO.CreateViewerStreams["IO test"]; out.PutRope["\nIOTestImpl started\n"]; TestLoop[]; out.PutRope["\nIOTestImpl ended\n"]; in.Close[]; out.Close[]; END. *File: IOTestImpl.mesa Last edited by MBrown on October 21, 1983 11:51 pm Utilities TestLoop TestSimpleStreams TestEditedStreams TestIOClasses TestPrint TestScan TestConvert Start Code { ENABLE RuntimeError.BoundsFault => { out.PutRope["BoundsFault\n"]; CONTINUE }; x: INT _ 37777777777B; }; Κr˜Jšœ™Jšœ2™2˜šΟk ˜ Jšœ˜J˜ Jšœ˜Jšœ˜Jšœ ˜ Jšœ˜Jšœ˜J˜ J˜——šœ ˜š˜Jšœ˜J˜ Jšœ˜Jšœ˜Jšœ ˜ Jšœ˜Jšœ˜J˜—Jšœ˜Jšœœœ˜Jšœœœœ˜Jšœœœ˜Jšœ œœ ˜Jšœ œœ ˜!—headšΟn ™ Jšœœœ˜Jšœ œœ˜unitšžœœ œ˜ codeš˜Mšœœœ˜2Mšœ˜—M˜—šžœœ œ˜"Mšœ œ˜MšœΟc˜)Mšœ Ÿ˜(M˜—šžœœ œ˜)Mšœ˜M˜—šžœœœœ˜9Mšœœ˜šœœ œ˜"Mšœœ ˜M˜!Mšœ˜—šœ ˜M˜Mšœœœ˜*Mšœœ˜Mšœ˜—M˜—š žœœ œœœ˜5š˜Mš œœœœœ˜/Mšœ'˜'M˜Mš˜—M˜——šž™šžœœ˜M˜M˜M˜M˜ M˜ M˜M˜——šž™šžœœ˜Mšœ!œ˜+Mšœœ˜#Mšœœ˜#Mšœœ˜#Mšœœ˜#M˜—šžœœ˜Mšœœ˜ Mš œœœ œœ˜&Mšœ œœœœœ œœ ˜BM˜)Mšœœ˜M˜&M˜"M˜ M˜ M˜M˜Mšœœ˜5M˜ M˜M˜Mšœœ˜M˜%M˜"M˜ M˜ Mšœ˜Mšœ˜šœœœ˜/Mšœœ˜Mšœ˜M˜—š œœ œœœœœ˜OMšœœ˜Mšœ˜M˜—Mšœ(˜(Mšœ œ˜AM˜'M˜—šžœœ˜Mšœœ˜ Mšœœ˜M˜!M˜Mšœœœ˜M˜%M˜"M˜M˜M˜#M˜ M˜M˜ J˜Mšœœœ˜Mšœ!˜!M˜ J˜Mšœœœ˜Mšœ!˜!M˜ M˜M˜—šžœœ˜Mšœœ˜ Mšœœ˜#Mšœœ˜Mšœ!˜!M˜Mšœœœ˜M˜%M˜"M˜M˜M˜!M˜ M˜M˜ M˜Mšœœœ˜Mšœ!˜!M˜ M™Mšœœœ˜Mšœ!˜!M˜ M˜M˜—šžœœ˜Mšœœ˜ Mšœœ˜Mšœœ˜"M˜!M˜Mšœœœ˜ M˜&M˜"M˜M˜M˜M˜ Mšœ&˜&J˜Mšœœœ˜M˜Mšœ*œ˜2M˜Mšœ4˜4M˜M˜—šžœœ˜Mšœœ˜ Mšœœ˜Mšœœ˜"M˜!M˜Mšœœœ˜ M˜&M˜"M˜M˜M˜M˜ Mšœ?˜?J˜Mšœœœœ˜M˜Mšœ?˜?M˜MšœM˜MM˜M˜——šž™šžœœ˜M˜+šœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ!˜!—šœ˜JšœT˜TJšœ;˜;Jšœ@˜@Jšœ!˜!—šœ˜Jšœ5˜5Jšœ<˜