Skip to content

In tests that expect multi-line strings, use a query that prints a table of (ordinal, line) pairs #336

@julianhyde

Description

@julianhyde

In tests that expect multi-line strings, use a query that prints a table of (ordinal, line) pairs.

For example, the test

Sys.planEx "0";
> val it =
>   "val it = let val isDept = fn d => op elem$0 (d, #depts scott) in from d_1 : {deptno:int, dname:string, loc:string} where isDept d_1 andalso #deptno d_1 = 20 yield #dname d_1 end"
>   : string

should be replaced by

set ("output","tabular");
> val it = () : unit
from line in Sys.lines (Sys.planEx "0") yield {a=ordinal, line};
> a line
> - ----
> 0 val it =
> 1   let
> 2     val isDept = fn d => op elem$0 (d, #depts scott) 
> 3   in
> 4     from d_1 : {deptno:int, dname:string, loc:string}
> 5       where isDept d_1
> 6         andalso #deptno d_1 = 20
> 7       yield #dname d_1
> 8     end
>
> val it : {a:int, line:string} list

Components:

  • The lines function breaks a string with line endings into a list
  • There is another function (not shown) that converts a Morel program into a Morel program formatted with whitespaces and line breaks
  • Because the query returns a list of records, the tabular format (added in Tabular mode #259) prints each record as a line

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions