summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ccgbugs/t7079.nim9
-rw-r--r--tests/concepts/t3330.nim37
-rw-r--r--tests/discard/tneedsdiscard.nim2
-rw-r--r--tests/errmsgs/tdetailed_position.nim22
-rw-r--r--tests/errmsgs/twrongcolon.nim11
-rw-r--r--tests/exception/texcas.nim10
-rw-r--r--tests/generics/tspecial_numeric_inference.nim12
-rw-r--r--tests/system/io.nim25
8 files changed, 118 insertions, 10 deletions
diff --git a/tests/ccgbugs/t7079.nim b/tests/ccgbugs/t7079.nim
new file mode 100644
index 000000000..bfa1b77a6
--- /dev/null
+++ b/tests/ccgbugs/t7079.nim
@@ -0,0 +1,9 @@
+discard """
+  action: run
+  targets: '''c js'''
+"""
+
+import math
+let x = -0.0
+doAssert classify(x) == fcNegZero
+doAssert classify(1 / -0.0) == fcNegInf
\ No newline at end of file
diff --git a/tests/concepts/t3330.nim b/tests/concepts/t3330.nim
index bf8bffc7d..6c9883618 100644
--- a/tests/concepts/t3330.nim
+++ b/tests/concepts/t3330.nim
@@ -1,25 +1,48 @@
 discard """
 errormsg: "type mismatch: got (Bar[system.int])"
 nimout: '''
-t3330.nim(40, 4) Error: type mismatch: got (Bar[system.int])
+t3330.nim(63, 4) Error: type mismatch: got (Bar[system.int])
 but expected one of:
 proc test(foo: Foo[int])
-t3330.nim(25, 8) Hint: Non-matching candidates for add(k, string, T)
+t3330.nim(48, 8) Hint: Non-matching candidates for add(k, string, T)
 proc add(x: var string; y: string)
+first type mismatch at position: 1
+required type: var string
+but expression 'k' is of type: Alias
 proc add(x: var string; y: char)
+first type mismatch at position: 1
+required type: var string
+but expression 'k' is of type: Alias
 proc add(result: var string; x: int64)
+first type mismatch at position: 1
+required type: var string
+but expression 'k' is of type: Alias
 proc add(result: var string; x: float)
+first type mismatch at position: 1
+required type: var string
+but expression 'k' is of type: Alias
 proc add(x: var string; y: cstring)
+first type mismatch at position: 1
+required type: var string
+but expression 'k' is of type: Alias
 proc add[T](x: var seq[T]; y: openArray[T])
+first type mismatch at position: 1
+required type: var seq[T]
+but expression 'k' is of type: Alias
 proc add[T](x: var seq[T]; y: T)
+first type mismatch at position: 1
+required type: var seq[T]
+but expression 'k' is of type: Alias
 
-t3330.nim(25, 8) template/generic instantiation from here
-t3330.nim(32, 6) Foo: 'bar.value' cannot be assigned to
-t3330.nim(25, 8) template/generic instantiation from here
-t3330.nim(33, 6) Foo: 'bar.x' cannot be assigned to
-'''
+t3330.nim(48, 8) template/generic instantiation from here
+t3330.nim(55, 6) Foo: 'bar.value' cannot be assigned to
+t3330.nim(48, 8) template/generic instantiation from here
+t3330.nim(56, 6) Foo: 'bar.x' cannot be assigned to
+
+expression: test(bar)'''
 """
 
+
 type
   Foo[T] = concept k
     add(k, string, T)
diff --git a/tests/discard/tneedsdiscard.nim b/tests/discard/tneedsdiscard.nim
index 509e8233b..8d59e7fec 100644
--- a/tests/discard/tneedsdiscard.nim
+++ b/tests/discard/tneedsdiscard.nim
@@ -1,6 +1,6 @@
 discard """
   line: 10
-  errormsg: '''expression 'open(f, "arg.txt", fmRead, -1)' is of type 'bool' and has to be discarded'''
+  errormsg: '''expression 'open(f, "arg.txt", fmRead, -1)' is of type 'bool' and has to be discarded; start of expression here: tneedsdiscard.nim(7, 2)'''
 """
 
 proc p =
diff --git a/tests/errmsgs/tdetailed_position.nim b/tests/errmsgs/tdetailed_position.nim
new file mode 100644
index 000000000..d6db94c3e
--- /dev/null
+++ b/tests/errmsgs/tdetailed_position.nim
@@ -0,0 +1,22 @@
+
+discard """
+cmd: "nim check $file"
+errormsg: "type mismatch: got (int literal(1), int literal(2), int literal(3))"
+nimout: '''
+but expected one of:
+proc main(a, b, c: string)
+first type mismatch at position: 1
+required type: string
+but expression '1' is of type: int literal(1)
+
+expression: main(1, 2, 3)
+'''
+"""
+
+const
+  myconst = "abcdefghijklmnopqrstuvwxyz"
+
+proc main(a, b, c: string) {.deprecated: "use foo " & "instead " & myconst.} =
+  return
+
+main(1, 2, 3)
diff --git a/tests/errmsgs/twrongcolon.nim b/tests/errmsgs/twrongcolon.nim
new file mode 100644
index 000000000..6f5cc3e5d
--- /dev/null
+++ b/tests/errmsgs/twrongcolon.nim
@@ -0,0 +1,11 @@
+discard """
+errormsg: "in expression '("
+nimout: '''
+Error: in expression '(
+  890)': identifier expected, but found ''
+'''
+
+line: 11
+"""
+
+var n: int : 890
diff --git a/tests/exception/texcas.nim b/tests/exception/texcas.nim
index 4b4ebe448..fee45af3f 100644
--- a/tests/exception/texcas.nim
+++ b/tests/exception/texcas.nim
@@ -21,5 +21,13 @@ proc test2() =
   testTemplate(Exception)
   doAssert(not declared(foobar))
 
+
+proc testTryAsExpr(i: int) =
+  let x = try: i    
+  except ValueError as ex:
+    echo(ex.msg)
+    -1
+
 test[Exception]()
-test2()
\ No newline at end of file
+test2()
+testTryAsExpr(5)
diff --git a/tests/generics/tspecial_numeric_inference.nim b/tests/generics/tspecial_numeric_inference.nim
new file mode 100644
index 000000000..d93544ba4
--- /dev/null
+++ b/tests/generics/tspecial_numeric_inference.nim
@@ -0,0 +1,12 @@
+discard """
+  output: '''int64
+int64'''
+"""
+
+import typetraits
+
+proc `@`[T: SomeInteger](x, y: T): T = x
+
+echo(type(5'i64 @ 6'i32))
+
+echo(type(5'i32 @ 6'i64))
diff --git a/tests/system/io.nim b/tests/system/io.nim
index b0ccfda9f..3d4df806b 100644
--- a/tests/system/io.nim
+++ b/tests/system/io.nim
@@ -1,5 +1,5 @@
 import
-  unittest, osproc, streams, os
+  unittest, osproc, streams, os, strformat
 const STRING_DATA = "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."
 const TEST_FILE = "tests/testdata/string.txt"
 
@@ -23,3 +23,26 @@ suite "io":
     test "file":
       check:
         readFile(TEST_FILE) == STRING_DATA
+
+
+proc verifyFileSize(sz: int64) =
+  # issue 7121, large file size (2-4GB and >4Gb)
+  const fn = "tmpfile112358"
+  let size_in_mb = sz div 1_000_000
+
+  when defined(windows):
+    discard execProcess(&"fsutil file createnew {fn} {sz}" )
+  else:
+    discard execProcess(&"dd if=/dev/zero of={fn} bs=1000000 count={size_in_mb}")
+
+  doAssert os.getFileSize(fn) == sz # Verify OS filesize by string
+  
+  var f = open(fn)
+  doAssert f.getFileSize() == sz # Verify file handle filesize
+  f.close()
+
+  os.removeFile(fn)
+
+#disable tests for automatic testers
+#for s in [50_000_000'i64, 3_000_000_000, 5_000_000_000]:
+#  verifyFileSize(s)
> 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670