diff options
author | Araq <rumpf_a@web.de> | 2012-04-16 16:31:15 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2012-04-16 16:31:15 +0200 |
commit | 17d67ab82827d10203646066d4d203d1da26a75a (patch) | |
tree | c33e78f4817685c71b2f8d4e5ed41948298067c7 | |
parent | a6564092869db9af93b6440006c8b978bff6e17f (diff) | |
download | Nim-17d67ab82827d10203646066d4d203d1da26a75a.tar.gz |
fixes #105
-rwxr-xr-x | compiler/ccgtypes.nim | 6 | ||||
-rw-r--r-- | icons/koch_icon.o | bin | 5768 -> 0 bytes | |||
-rw-r--r-- | icons/nimrod_icon.o | bin | 30830 -> 0 bytes | |||
-rwxr-xr-x | tests/compile/tsortdev.nim | 81 | ||||
-rwxr-xr-x | tests/run/tsortdev.nim | 59 | ||||
-rw-r--r-- | tests/testdata/string | 1 | ||||
-rwxr-xr-x | todo.txt | 1 |
7 files changed, 63 insertions, 85 deletions
diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim index 3578b1f5e..a7ad44db6 100755 --- a/compiler/ccgtypes.nim +++ b/compiler/ccgtypes.nim @@ -269,7 +269,9 @@ proc genProcParams(m: BModule, t: PType, rettype, params: var PRope, var arr = param.typ if arr.kind == tyVar: arr = arr.sons[0] var j = 0 - while arr.Kind == tyOpenArray: + while arr.Kind == tyOpenArray: + # this fixes the 'sort' bug: + if param.typ.kind == tyVar: param.loc.s = OnUnknown # need to pass hidden parameter: appff(params, ", NI $1Len$2", ", @NI $1Len$2", [param.loc.r, j.toRope]) inc(j) @@ -288,7 +290,7 @@ proc genProcParams(m: BModule, t: PType, rettype, params: var PRope, if tfVarargs in t.flags: if params != nil: app(params, ", ") app(params, "...") - if (params == nil) and (gCmd != cmdCompileToLLVM): app(params, "void)") + if params == nil and gCmd != cmdCompileToLLVM: app(params, "void)") else: app(params, ")") params = con("(", params) diff --git a/icons/koch_icon.o b/icons/koch_icon.o deleted file mode 100644 index b780f4d88..000000000 --- a/icons/koch_icon.o +++ /dev/null Binary files differdiff --git a/icons/nimrod_icon.o b/icons/nimrod_icon.o deleted file mode 100644 index c8c364412..000000000 --- a/icons/nimrod_icon.o +++ /dev/null Binary files differdiff --git a/tests/compile/tsortdev.nim b/tests/compile/tsortdev.nim deleted file mode 100755 index 1b7705d81..000000000 --- a/tests/compile/tsortdev.nim +++ /dev/null @@ -1,81 +0,0 @@ -discard """ - disabled: false -""" - -import math, algorithm - -proc sorted[T](a: openArray[T], order: TSortOrder): bool = - result = true - for i in 0 .. < a.high: - if cmp(a[i], a[i+1]) * order > 0: - echo "Out of order: ", a[i], " ", a[i+1] - result = false - -proc bubbleSort[T](a: var openArray[T], - cmp: proc (x, y: T): int, - order = TSortOrder.Ascending) = - while true: - var sorted = true - for i in 0 .. a.len-2: - if cmp(a[i], a[i+1]) * order > 0: - swap(a[i], a[i+1]) - sorted = false - if sorted: break - -when isMainModule: - proc main() = - const order = Ascending - var data: seq[string] = @[] - - var L = random(59) - for i in 0..2: - #echo "loop: ", i - #newSeq(data, L) - setLen(data, L) - for j in 0 .. L-1: - data[j] = $(math.random(90) - 10) - assert getRefcount(data[j]) == 1 - {.watchpoint: data.} - var copy = data - for j in 0 .. L-1: - assert getRefcount(copy[j]) == 1 - assert(cast[pointer](copy[j]) != cast[pointer](data[j])) - - bubblesort(data, system.cmp, order) - if not sorted(data, order): - quit "bubblesort failed" - - sort(copy, cmp, order) - for j in 0 .. L-1: - let rc = getRefcount(data[j]) - if rc != 1: - echo "RC IST ", rc, " j: ", j - assert getRefcount(data[j]) == 1 - when false: - if copy.len != data.len: - quit "lengths differ!" - for i in 0 .. copy.high: - if copy[i] != data[i]: - quit "algorithms differ!" - when false: - for i in 0..10_000: - var data: seq[int] - var L = random(59) - newSeq(data, L) - for j in 0 .. L-1: - data[j] = (math.random(90) - 10) - var copy = data - sort(data, cmp[int], order) - if not sorted(data, order): - quit "sort for seq[int] failed" - bubblesort(copy, system.cmp[int], order) - if copy.len != data.len: - quit "lengths differ!" - for i in 0 .. copy.high: - if copy[i] != data[i]: - quit "algorithms differ!" - - main() - -echo "done" - diff --git a/tests/run/tsortdev.nim b/tests/run/tsortdev.nim new file mode 100755 index 000000000..d7d42d22c --- /dev/null +++ b/tests/run/tsortdev.nim @@ -0,0 +1,59 @@ +discard """ + output: "done" +""" + +import algorithm, strutils + +proc cmpPlatforms(a, b: string): int = + if a == b: return 0 + var dashes = a.split('-') + var dashes2 = b.split('-') + if dashes[0] == dashes2[0]: + if dashes[1] == dashes2[1]: return system.cmp(a,b) + case dashes[1] + of "x86": + return 1 + of "x86_64": + if dashes2[1] == "x86": return -1 + else: return 1 + of "ppc64": + if dashes2[1] == "x86" or dashes2[1] == "x86_64": return -1 + else: return 1 + else: + return system.cmp(dashes[1], dashes2[1]) + else: + case dashes[0] + of "linux": + return 1 + of "windows": + if dashes2[0] == "linux": return -1 + else: return 1 + of "macosx": + if dashes2[0] == "linux" or dashes2[0] == "windows": return -1 + else: return 1 + else: + if dashes2[0] == "linux" or dashes2[0] == "windows" or + dashes2[0] == "macosx": return -1 + else: + return system.cmp(a, b) + +proc sorted[T](a: openArray[T]): bool = + result = true + for i in 0 .. < a.high: + if cmpPlatforms(a[i], a[i+1]) > 0: + echo "Out of order: ", a[i], " ", a[i+1] + result = false + +proc main() = + var testData = @["netbsd-x86_64", "windows-x86", "linux-x86_64", "linux-x86", + "linux-ppc64", "macosx-x86-1058", "macosx-x86-1068"] + + sort(testData, cmpPlatforms) + + doAssert sorted(testData) + +for i in 0..1_000: + main() + +echo "done" + diff --git a/tests/testdata/string b/tests/testdata/string deleted file mode 100644 index 41bfe81b8..000000000 --- a/tests/testdata/string +++ /dev/null @@ -1 +0,0 @@ -Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. \ No newline at end of file diff --git a/todo.txt b/todo.txt index 2ba5a2ff0..7e037605c 100755 --- a/todo.txt +++ b/todo.txt @@ -45,7 +45,6 @@ Bugs without ``-d:release`` leaks memory? - bug: object {.pure, final.} does not work again! - bug: {.error: "msg".} produces invalid pragma message -- bug: tsortdev does not run with native GC!! - bug: pragma statements in combination with symbol files are evaluated twice but this can lead to compilation errors |