about summary refs log tree commit diff stats
path: root/053new-segment.subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-06-13 14:20:35 -0700
committerKartik Agaram <vc@akkartik.com>2019-06-13 14:20:35 -0700
commitb5f80415d6fdc6f80088c807b749138972e1c546 (patch)
tree92e2a907f8530c938bc0d3e40ae417dd65e3e153 /053new-segment.subx
parentacdd7a7a68d26f5f189fe52c6f96bb2c51025eb1 (diff)
downloadmu-b5f80415d6fdc6f80088c807b749138972e1c546.tar.gz
pseudocode skeletons for all functions
Diffstat (limited to '053new-segment.subx')
0 files changed, 0 insertions, 0 deletions
green' href='/ahoang/Nim/commit/nimpretty/tester.nim?h=devel&id=837d0c7270a67ea632d492586843807075eefb88'>837d0c727 ^
06a6433db ^
dd252ce64 ^
837d0c727 ^
1be82d96a ^
837d0c727 ^




06a6433db ^






837d0c727 ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42









                                        
                      
                                                     




                                                                       

                                                                                               


                                                      

                                                    
                                                 
                                              
                                           
                                                                   




                                              






                                                 

                                                        
# Small program that runs the test cases

import strutils, os

const
  dir = "nimpretty/tests/"

var
  failures = 0

when defined(develop):
  const nimp = "bin" / "nimpretty".addFileExt(ExeExt)
  if execShellCmd("nim c -o:$# nimpretty/nimpretty.nim" % [nimp]) != 0:
    quit("FAILURE: compilation of nimpretty failed")
else:
  const nimp = "nimpretty"

proc test(infile, ext: string) =
  if execShellCmd("$# -o:$# --backup:off $#" % [nimp, infile.changeFileExt(ext), infile]) != 0:
    echo "FAILURE: nimpretty cannot prettify ", infile
    failures += 1
    return
  let nimFile = splitFile(infile).name
  let expected = dir / "expected" / nimFile & ".nim"
  let produced = dir / nimFile.changeFileExt(ext)
  if readFile(expected) != readFile(produced):
    echo "FAILURE: files differ: ", nimFile
    discard execShellCmd("diff -uNdr " & expected & " " & produced)
    failures += 1
  else:
    echo "SUCCESS: files identical: ", nimFile

for t in walkFiles(dir / "*.nim"):
  test(t, "pretty")
  # also test that pretty(pretty(x)) == pretty(x)
  test(t.changeFileExt("pretty"), "pretty2")

  removeFile(t.changeFileExt("pretty"))
  removeFile(t.changeFileExt("pretty2"))


if failures > 0: quit($failures & " failures occurred.")