mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-06 13:07:48 +00:00
@@ -1,5 +1,5 @@
|
||||
discard """
|
||||
ouput: '''foo
|
||||
output: '''foo
|
||||
true'''
|
||||
"""
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
discard """
|
||||
line: "13"
|
||||
errormsg: "for a 'var' type a variable needs to be passed"
|
||||
errormsg: "type mismatch: got (int literal(8), int literal(5), int, int)"
|
||||
"""
|
||||
|
||||
proc divmod(a, b: int, res, remainder: var int) =
|
||||
|
||||
@@ -5,7 +5,8 @@ import
|
||||
from strutils import
|
||||
formatFloat,
|
||||
TFloatFormat,
|
||||
`%`
|
||||
`%`,
|
||||
ffDecimal
|
||||
|
||||
from unsigned import
|
||||
`shr`,
|
||||
|
||||
@@ -54,7 +54,7 @@ else:
|
||||
glRealType* = cGLfloat
|
||||
|
||||
proc setUniformV4*[T](loc: GLint, vecs: var openarray[TV4[T]]) =
|
||||
glUniform4fv(loc, vecs.len.GLsizei, cast[PGLfloat](vecs[0].addr))
|
||||
glUniform4fv(loc, vecs.len.GLsizei, cast[ptr GLfloat](vecs[0].addr))
|
||||
|
||||
proc setUniformV4*[T](loc: GLint, vec: TV4[T]) =
|
||||
var vecs = [vec]
|
||||
|
||||
@@ -16,7 +16,7 @@ type
|
||||
i* : GLuint
|
||||
size* : GLint
|
||||
stride* : GLsizei
|
||||
offset* : PGLvoid
|
||||
offset* : GLvoid
|
||||
TVertMode* = enum
|
||||
vmTriStrip = GLtriangleStrip,
|
||||
vmTriFan = GLtriangleFan
|
||||
@@ -44,7 +44,7 @@ proc newVertQuad*(min, minRight, maxLeft, max: TV2[TR]): seq[TVert] =
|
||||
proc newVert*(rect: rect.TRect): seq[TVert] =
|
||||
newVertQuad(rect.min, newV2(rect.max.x, rect.min.y), newV2(rect.min.x, rect.max.y), rect.max)
|
||||
|
||||
proc newVertAttrib(i: GLuint, size: GLint, stride: GLsizei, offset: PGLvoid): TVertAttrib =
|
||||
proc newVertAttrib(i: GLuint, size: GLint, stride: GLsizei, offset: GLvoid): TVertAttrib =
|
||||
TVertAttrib(i: i, size: size, stride: stride, offset: offset)
|
||||
|
||||
proc genBuf*[T](vboTarget, objUsage: GLenum, data: var openarray[T]): GLuint =
|
||||
@@ -90,7 +90,7 @@ proc disableVertAttribArrs*() =
|
||||
proc setVertAttribPointers*() =
|
||||
let vertSize {.global.} = TVert.sizeof.GLint
|
||||
?glVertexAttribPointer(0, 2, glRealType, false, vertSize, nil)
|
||||
?glVertexAttribPointer(1, 2, glRealType, false, vertSize, cast[PGLvoid](TR.sizeof * 2))
|
||||
?glVertexAttribPointer(1, 2, glRealType, false, vertSize, cast[GLvoid](TR.sizeof * 2))
|
||||
|
||||
proc updVerts*(o: PPrimitive, start, `end`: int, f: proc(i: int, vert: var TVert)) =
|
||||
assert start <= `end`
|
||||
@@ -105,7 +105,7 @@ proc updVerts*(o: PPrimitive, start, `end`: int, f: proc(i: int, vert: var TVert
|
||||
?glBufferSubData(GLarrayBuffer,
|
||||
byteOffset.GLintptr, # Offset. Is this right?
|
||||
byteLen.GLsizeiptr, # Size.
|
||||
cast[PGLvoid](cast[int](o.verts[0].addr) + byteOffset))
|
||||
cast[GLvoid](cast[int](o.verts[0].addr) + byteOffset))
|
||||
|
||||
proc updAllVerts(o: PPrimitive, f: proc(i: int, vert: var TVert)) =
|
||||
for i in 0 .. <o.verts.len:
|
||||
|
||||
@@ -25,7 +25,7 @@ proc setSrc*(shader: TShader, src: string) =
|
||||
?glShaderSource(shader.id, 1, cast[cstringarray](s.addr), nil)
|
||||
|
||||
proc newShader*(id: GL_handle): TShader =
|
||||
if id != 0 and not (?glIsShader(id)).bool:
|
||||
if id.int != 0 and not (?glIsShader(id)).bool:
|
||||
raise newException(E_GL, "Invalid shader ID: " & $id)
|
||||
|
||||
result.id = id
|
||||
@@ -33,7 +33,7 @@ proc newShader*(id: GL_handle): TShader =
|
||||
proc shaderInfoLog*(o: TShader): string =
|
||||
var log {.global.}: array[0..1024, char]
|
||||
var logLen: GLsizei
|
||||
?glGetShaderInfoLog(o.id, log.len.GLsizei, logLen, cast[PGLchar](log.addr))
|
||||
?glGetShaderInfoLog(o.id.GLuint, log.len.GLsizei, addr logLen, cast[cstring](log.addr))
|
||||
cast[string](log.addr).substr(0, logLen)
|
||||
|
||||
proc compile*(shader: TShader, path="") =
|
||||
@@ -67,7 +67,7 @@ proc attach*(o: TProgram, shader: TShader) =
|
||||
proc infoLog*(o: TProgram): string =
|
||||
var log {.global.}: array[0..1024, char]
|
||||
var logLen: GLsizei
|
||||
?glGetProgramInfoLog(o.id, log.len.GLsizei, logLen, cast[PGLchar](log.addr))
|
||||
?glGetProgramInfoLog(o.id.GLuint, log.len.GLsizei, addr logLen, cast[cstring](log.addr))
|
||||
cast[string](log.addr).substr(0, logLen)
|
||||
|
||||
proc link*(o: TProgram) =
|
||||
@@ -86,11 +86,11 @@ proc validate*(o: TProgram) =
|
||||
|
||||
proc newProgram*(shaders: seq[TShader]): TProgram =
|
||||
result.id = ?glCreateProgram()
|
||||
if result.id == 0:
|
||||
if result.id.int == 0:
|
||||
return
|
||||
|
||||
for shader in shaders:
|
||||
if shader.id == 0:
|
||||
if shader.id.int == 0:
|
||||
return
|
||||
|
||||
?result.attach(shader)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
discard """
|
||||
file: "tinc.nim"
|
||||
line: 8
|
||||
errormsg: "for a \'var\' type a variable needs to be passed"
|
||||
errormsg: "type mismatch: got (int)"
|
||||
"""
|
||||
var x = 0
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
discard """
|
||||
file: "tinout.nim"
|
||||
line: 12
|
||||
errormsg: "for a \'var\' type a variable needs to be passed"
|
||||
errormsg: "type mismatch: got (int literal(3))"
|
||||
"""
|
||||
# Test in out checking for parameters
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
discard """
|
||||
file: "tadrdisc.nim"
|
||||
line: 20
|
||||
errormsg: "for a \'var\' type a variable needs to be passed"
|
||||
errormsg: "type mismatch: got (TKind)"
|
||||
"""
|
||||
# Test that the address of a dicriminants cannot be taken
|
||||
|
||||
@@ -12,12 +12,9 @@ type
|
||||
of ka: x, y: int
|
||||
of kb: a, b: string
|
||||
of kc: c, d: float
|
||||
|
||||
proc setKind(k: var TKind) =
|
||||
|
||||
proc setKind(k: var TKind) =
|
||||
k = kc
|
||||
|
||||
|
||||
var a: TA
|
||||
setKind(a.k) #ERROR_MSG for a 'var' type a variable needs to be passed
|
||||
|
||||
|
||||
|
||||
setKind(a.k)
|
||||
|
||||
@@ -215,7 +215,7 @@ proc manyLoc(r: var TResults, cat: Category, options: string) =
|
||||
for kind, dir in os.walkDir("tests/manyloc"):
|
||||
if kind == pcDir:
|
||||
let mainfile = findMainFile(dir)
|
||||
if mainfile != ".nim":
|
||||
if mainfile != "":
|
||||
testNoSpec r, makeTest(mainfile, options, cat)
|
||||
|
||||
proc compileExample(r: var TResults, pattern, options: string, cat: Category) =
|
||||
|
||||
@@ -146,7 +146,6 @@ proc codegenCheck(test: TTest, check: string, given: var TSpec) =
|
||||
try:
|
||||
let (path, name, ext2) = test.name.splitFile
|
||||
let genFile = generatedFile(path, name, test.target)
|
||||
echo genFile
|
||||
let contents = readFile(genFile).string
|
||||
if check[0] == '\\':
|
||||
# little hack to get 'match' support:
|
||||
|
||||
Reference in New Issue
Block a user