Merge branch 'devel' into araq-devel

This commit is contained in:
Andreas Rumpf 2018-07-04 19:25:53 +02:00
commit 86a7054c88
16 changed files with 151 additions and 43 deletions

9
tests/errmsgs/t6281.nim Normal file
View file

@ -0,0 +1,9 @@
discard """
errormsg: "invalid type: 'SomeNumber' in this context: 'seq[SomeNumber]' for var"
line: 6
"""
var seqwat: seq[SomeNumber] = @[]
proc foo(x: SomeNumber) =
seqwat.add(x)

View file

@ -0,0 +1,9 @@
# test the valid literals
assert 0b10 == 2
assert 0B10 == 2
assert 0x10 == 16
assert 0X10 == 16
assert 0o10 == 8
# the following is deprecated:
assert 0c10 == 8
assert 0C10 == 8

View file

@ -0,0 +1,7 @@
discard """
file: "tinvalidintegerliteral3.nim"
line: 7
errormsg: "0O5 is an invalid int literal; For octal literals use the '0o' prefix."
"""
echo 0O5

View file

@ -9,7 +9,7 @@ discard """
# 8 bit
let ref1 = 128'u8 shr 7
let hex1 = 0x80'u8 shr 7
let oct1 = 0c200'u8 shr 7
let oct1 = 0o200'u8 shr 7
let dig1 = 0b10000000'u8 shr 7
doAssert(ref1 == 1)
@ -20,7 +20,7 @@ doAssert(ref1 == dig1)
# 16 bit
let ref2 = 32768'u16 shr 15
let hex2 = 0x8000'u16 shr 15
let oct2 = 0c100000'u16 shr 15
let oct2 = 0o100000'u16 shr 15
let dig2 = 0b1000000000000000'u16 shr 15
doAssert(ref2 == 1)
@ -31,7 +31,7 @@ doAssert(ref2 == dig2)
# 32 bit
let ref3 = 2147483648'u32 shr 31
let hex3 = 0x80000000'u32 shr 31
let oct3 = 0c20000000000'u32 shr 31
let oct3 = 0o20000000000'u32 shr 31
let dig3 = 0b10000000000000000000000000000000'u32 shr 31
doAssert(ref3 == 1)

View file

@ -107,3 +107,12 @@ when true:
assert aw2.data.high == 6
assert aw3.data.high == 9
# #6077
block:
type
Backend = enum
Cpu
Tensor[B: static[Backend]; T] = object
BackProp[B: static[Backend],T] = proc (gradient: Tensor[B,T]): Tensor[B,T]

41
tests/stdlib/tospaths.nim Normal file
View file

@ -0,0 +1,41 @@
discard """
file: "tospaths.nim"
output: ""
"""
# test the ospaths module
import os
doAssert unixToNativePath("") == ""
doAssert unixToNativePath(".") == $CurDir
doAssert unixToNativePath("..") == $ParDir
doAssert isAbsolute(unixToNativePath("/"))
doAssert isAbsolute(unixToNativePath("/", "a"))
doAssert isAbsolute(unixToNativePath("/a"))
doAssert isAbsolute(unixToNativePath("/a", "a"))
doAssert isAbsolute(unixToNativePath("/a/b"))
doAssert isAbsolute(unixToNativePath("/a/b", "a"))
doAssert unixToNativePath("a/b") == joinPath("a", "b")
when defined(macos):
doAssert unixToNativePath("./") == ":"
doAssert unixToNativePath("./abc") == ":abc"
doAssert unixToNativePath("../abc") == "::abc"
doAssert unixToNativePath("../../abc") == ":::abc"
doAssert unixToNativePath("/abc", "a") == "abc"
doAssert unixToNativePath("/abc/def", "a") == "abc:def"
elif doslikeFileSystem:
doAssert unixToNativePath("./") == ".\\"
doAssert unixToNativePath("./abc") == ".\\abc"
doAssert unixToNativePath("../abc") == "..\\abc"
doAssert unixToNativePath("../../abc") == "..\\..\\abc"
doAssert unixToNativePath("/abc", "a") == "a:\\abc"
doAssert unixToNativePath("/abc/def", "a") == "a:\\abc\\def"
else:
#Tests for unix
doAssert unixToNativePath("./") == "./"
doAssert unixToNativePath("./abc") == "./abc"
doAssert unixToNativePath("../abc") == "../abc"
doAssert unixToNativePath("../../abc") == "../../abc"
doAssert unixToNativePath("/abc", "a") == "/abc"
doAssert unixToNativePath("/abc/def", "a") == "/abc/def"

11
tests/typerel/t8172.nim Normal file
View file

@ -0,0 +1,11 @@
discard """
line: 11
errormsg: "cannot convert array[0..0, string] to varargs[string]"
"""
proc f(v: varargs[string]) =
echo(v)
f("b", "c") # Works
f(["b", "c"]) # Works
f("b", ["c"]) # Fails