made tests green again

This commit is contained in:
Araq 2012-07-09 00:54:46 +02:00
commit 795afb0021
15 changed files with 38 additions and 30 deletions

View file

@ -898,7 +898,7 @@ proc evalTemplate*(n: PNode, sym: PSym): PNode =
proc evalTypeTrait*(n: PNode, context: PSym): PNode = proc evalTypeTrait*(n: PNode, context: PSym): PNode =
## XXX: This should be pretty much guaranteed to be true ## XXX: This should be pretty much guaranteed to be true
# by the type traits procs' signitures, but until the # by the type traits procs' signatures, but until the
# code is more mature it doesn't hurt to be extra safe # code is more mature it doesn't hurt to be extra safe
internalAssert n.sons.len >= 2 and internalAssert n.sons.len >= 2 and
n.sons[1].sym.typ.kind == tyTypeDesc n.sons[1].sym.typ.kind == tyTypeDesc
@ -906,7 +906,7 @@ proc evalTypeTrait*(n: PNode, context: PSym): PNode =
let typ = n.sons[1].sym.typ.skipTypes({tyTypeDesc}) let typ = n.sons[1].sym.typ.skipTypes({tyTypeDesc})
case n.sons[0].sym.name.s case n.sons[0].sym.name.s
of "name": of "name":
result = newStrNode(nkStrLit, typ.typeToString) result = newStrNode(nkStrLit, typ.typeToString(preferExported))
result.typ = newType(tyString, context) result.typ = newType(tyString, context)
result.info = n.info result.info = n.info

View file

@ -17,7 +17,7 @@ proc lastOrd*(t: PType): biggestInt
proc lengthOrd*(t: PType): biggestInt proc lengthOrd*(t: PType): biggestInt
type type
TPreferedDesc* = enum TPreferedDesc* = enum
preferName, preferDesc preferName, preferDesc, preferExported
proc TypeToString*(typ: PType, prefer: TPreferedDesc = preferName): string proc TypeToString*(typ: PType, prefer: TPreferedDesc = preferName): string
proc getProcHeader*(sym: PSym): string proc getProcHeader*(sym: PSym): string
@ -404,14 +404,14 @@ proc TypeToString(typ: PType, prefer: TPreferedDesc = preferName): string =
if t == nil: return if t == nil: return
if prefer == preferName and t.sym != nil and sfAnon notin t.sym.flags: if prefer == preferName and t.sym != nil and sfAnon notin t.sym.flags:
if t.kind == tyInt and isIntLit(t): if t.kind == tyInt and isIntLit(t):
return t.sym.Name.s & "(" & $t.n.intVal & ")" return t.sym.Name.s & " literal(" & $t.n.intVal & ")"
return t.sym.Name.s return t.sym.Name.s
case t.Kind case t.Kind
of tyInt: of tyInt:
if not isIntLit(t): if not isIntLit(t) or prefer == preferExported:
result = typeToStr[t.kind] result = typeToStr[t.kind]
else: else:
result = "intLit(" & $t.n.intVal & ")" result = "int literal(" & $t.n.intVal & ")"
of tyGenericBody, tyGenericInst, tyGenericInvokation: of tyGenericBody, tyGenericInst, tyGenericInvokation:
result = typeToString(t.sons[0]) & '[' result = typeToString(t.sons[0]) & '['
for i in countup(1, sonsLen(t) -1 -ord(t.kind != tyGenericInvokation)): for i in countup(1, sonsLen(t) -1 -ord(t.kind != tyGenericInvokation)):
@ -667,7 +667,13 @@ proc sameTuple(a, b: PType, c: var TSameTypeClosure): bool =
if sonsLen(a) == sonsLen(b): if sonsLen(a) == sonsLen(b):
result = true result = true
for i in countup(0, sonsLen(a) - 1): for i in countup(0, sonsLen(a) - 1):
result = SameTypeAux(a.sons[i], b.sons[i], c) var x = a.sons[i]
var y = b.sons[i]
if c.ignoreTupleFields:
x = skipTypes(x, {tyRange})
y = skipTypes(y, {tyRange})
result = SameTypeAux(x, y, c)
if not result: return if not result: return
if a.n != nil and b.n != nil and not c.ignoreTupleFields: if a.n != nil and b.n != nil and not c.ignoreTupleFields:
for i in countup(0, sonsLen(a.n) - 1): for i in countup(0, sonsLen(a.n) - 1):
@ -746,7 +752,7 @@ proc SameTypeAux(x, y: PType, c: var TSameTypeClosure): bool =
# increases bootstrapping time from 2.4s to 3.3s on my laptop! So we cheat # increases bootstrapping time from 2.4s to 3.3s on my laptop! So we cheat
# again: Since the recursion check is only to not get caught in an endless # again: Since the recursion check is only to not get caught in an endless
# recursion, we use a counter and only if it's value is over some # recursion, we use a counter and only if it's value is over some
# threshold we perform the expansive exact cycle check: # threshold we perform the expensive exact cycle check:
if c.recCheck < 3: if c.recCheck < 3:
inc c.recCheck inc c.recCheck
else: else:

View file

@ -38,7 +38,7 @@ add(window, windowbox)
discard signal_connect(window, "destroy", SIGNAL_FUNC(ex6.destroy), nil) discard signal_connect(window, "destroy", SIGNAL_FUNC(ex6.destroy), nil)
QuitState.Obj = QuitButton QuitState.Obj = QuitButton
quitState.SignalID = signal_connect_object(QuitState.Obj, "clicked", quitState.SignalID = signal_connect_object(QuitState.Obj, "clicked",
SIGNAL_FUNC(widgetDestroy), window) SIGNAL_FUNC(widgetDestroy), window).int32
QuitState.Disable = True QuitState.Disable = True
discard signal_connect(disablebutton, "clicked", discard signal_connect(disablebutton, "clicked",
SIGNAL_FUNC(disablesignal), addr(QuitState)) SIGNAL_FUNC(disablesignal), addr(QuitState))

View file

@ -5,7 +5,7 @@ const
WINDOW_HEIGHT = 300 WINDOW_HEIGHT = 300
var var
width, height: int width, height: cint
display: PDisplay display: PDisplay
screen: cint screen: cint
depth: int depth: int

View file

@ -1156,7 +1156,9 @@ proc `$` *(x: int64): string {.magic: "Int64ToStr", noSideEffect.}
## The stingify operator for an integer argument. Returns `x` ## The stingify operator for an integer argument. Returns `x`
## converted to a decimal string. ## converted to a decimal string.
proc `$` *(x: uint64): string {.noSideEffect.} when not defined(NimrodVM):
when not defined(ECMAScript):
proc `$` *(x: uint64): string {.noSideEffect.}
## The stingify operator for an unsigned integer argument. Returns `x` ## The stingify operator for an unsigned integer argument. Returns `x`
## converted to a decimal string. ## converted to a decimal string.

View file

@ -2649,7 +2649,7 @@ proc MCI_TMSF_FRAME(tmsf: int32): int8 =
result = toU8(tmsf shr 24) result = toU8(tmsf shr 24)
proc mci_Make_TMSF(t, m, s, f: int8): int32 = proc mci_Make_TMSF(t, m, s, f: int8): int32 =
result = ze(t) or ze(m) shl 8 or ze(s) shl 16 or ze(f) shl 24 result = (ze(t) or ze(m) shl 8 or ze(s) shl 16 or ze(f) shl 24).int32
proc DIBINDEX(n: int32): int32 = proc DIBINDEX(n: int32): int32 =
result = n Or 0x000010FF'i32 shl 16'i32 result = n Or 0x000010FF'i32 shl 16'i32

View file

@ -860,4 +860,4 @@ const
# implementation # implementation
proc EIRESID(x: int32): int32 = proc EIRESID(x: int32): int32 =
result = - int(x) result = -x

View file

@ -12,8 +12,8 @@ type
TRadixNode {.pure.} = object TRadixNode {.pure.} = object
kind: TRadixNodeKind kind: TRadixNodeKind
TRadixNodeLinear = object of TRadixNode TRadixNodeLinear = object of TRadixNode
len: byte len: int8
keys: array [0..31, byte] keys: array [0..31, int8]
vals: array [0..31, PRadixNode] vals: array [0..31, PRadixNode]
TRadixNodeFull = object of TRadixNode TRadixNodeFull = object of TRadixNode
@ -21,8 +21,8 @@ type
TRadixNodeLeafBits = object of TRadixNode TRadixNodeLeafBits = object of TRadixNode
b: array [0..7, int] b: array [0..7, int]
TRadixNodeLeafLinear = object of TRadixNode TRadixNodeLeafLinear = object of TRadixNode
len: byte len: int8
keys: array [0..31, byte] keys: array [0..31, int8]
var var
root: PRadixNode root: PRadixNode

View file

@ -6,7 +6,7 @@ type
TRadixNode = object TRadixNode = object
kind: TRadixNodeKind kind: TRadixNodeKind
TRadixNodeLinear = object of TRadixNode TRadixNodeLinear = object of TRadixNode
len: byte len: int8
keys: array [0..31, char] keys: array [0..31, char]
vals: array [0..31, PRadixNode] vals: array [0..31, PRadixNode]
TRadixNodeFull = object of TRadixNode TRadixNodeFull = object of TRadixNode

View file

@ -1,6 +1,6 @@
discard """ discard """
line: 15 line: 16
errormsg: "type mismatch: got (int)" errormsg: "type mismatch: got (int literal(232))"
""" """
proc myGenericProc[T: object|tuple|ptr|ref|distinct](x: T): string = proc myGenericProc[T: object|tuple|ptr|ref|distinct](x: T): string =
@ -12,7 +12,7 @@ type
var var
x: TMyObj x: TMyObj
assert myGenericProc(232) == "232"
assert myGenericProc(x) == "(x: 0, y: 0)" assert myGenericProc(x) == "(x: 0, y: 0)"
assert myGenericProc(232) == "232"

View file

@ -1,7 +1,7 @@
discard """ discard """
file: "tinvalidnewseq.nim" file: "tinvalidnewseq.nim"
line: 15 line: 15
errormsg: "type mismatch: got (array[0..6, string], int)" errormsg: "type mismatch: got (array[0..6, string], int literal(7))"
""" """
import re, strutils import re, strutils

View file

@ -1,7 +1,7 @@
discard """ discard """
file: "tnamedparams.nim" file: "tnamedparams.nim"
line: 8 line: 8
errormsg: "type mismatch: got (input: string, filename: string, line: int, col: int)" errormsg: "type mismatch: got (input: string, filename: string, line: int literal(1), col: int literal(23))"
""" """
import pegs import pegs

View file

@ -1,6 +1,6 @@
discard """ discard """
line: 6 line: 6
errormsg: "type mismatch: got (int) but expected 'bool'" errormsg: "type mismatch: got (int literal(1)) but expected 'bool'"
""" """
if 1: if 1:

View file

@ -1,6 +1,6 @@
discard """ discard """
line: 8 line: 8
msg: "type mismatch: got (int)" msg: "type mismatch: got (int literal(3))"
""" """
# please finally disallow Len(3) # please finally disallow Len(3)

View file

@ -1,5 +1,5 @@
discard """ discard """
output: "454 == 45ugh" output: "x == 45ugh"
""" """
template myAssert(cond: expr) = template myAssert(cond: expr) =
@ -8,6 +8,6 @@ template myAssert(cond: expr) =
if not cond: if not cond:
echo c, "ugh" echo c, "ugh"
var x = 454
myAssert(454 == 45) myAssert(x == 45)