made tests green again

This commit is contained in:
Araq
2012-07-09 00:54:46 +02:00
parent f0dd96fa58
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 =
## 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
internalAssert n.sons.len >= 2 and
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})
case n.sons[0].sym.name.s
of "name":
result = newStrNode(nkStrLit, typ.typeToString)
result = newStrNode(nkStrLit, typ.typeToString(preferExported))
result.typ = newType(tyString, context)
result.info = n.info

View File

@@ -17,7 +17,7 @@ proc lastOrd*(t: PType): biggestInt
proc lengthOrd*(t: PType): biggestInt
type
TPreferedDesc* = enum
preferName, preferDesc
preferName, preferDesc, preferExported
proc TypeToString*(typ: PType, prefer: TPreferedDesc = preferName): string
proc getProcHeader*(sym: PSym): string
@@ -404,14 +404,14 @@ proc TypeToString(typ: PType, prefer: TPreferedDesc = preferName): string =
if t == nil: return
if prefer == preferName and t.sym != nil and sfAnon notin t.sym.flags:
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
case t.Kind
of tyInt:
if not isIntLit(t):
if not isIntLit(t) or prefer == preferExported:
result = typeToStr[t.kind]
else:
result = "intLit(" & $t.n.intVal & ")"
result = "int literal(" & $t.n.intVal & ")"
of tyGenericBody, tyGenericInst, tyGenericInvokation:
result = typeToString(t.sons[0]) & '['
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):
result = true
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 a.n != nil and b.n != nil and not c.ignoreTupleFields:
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
# 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
# threshold we perform the expansive exact cycle check:
# threshold we perform the expensive exact cycle check:
if c.recCheck < 3:
inc c.recCheck
else:

View File

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

View File

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

View File

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

View File

@@ -2649,7 +2649,7 @@ proc MCI_TMSF_FRAME(tmsf: int32): int8 =
result = toU8(tmsf shr 24)
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 =
result = n Or 0x000010FF'i32 shl 16'i32

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,7 +1,7 @@
discard """
file: "tinvalidnewseq.nim"
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

View File

@@ -1,7 +1,7 @@
discard """
file: "tnamedparams.nim"
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

View File

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

View File

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

View File

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