summary refs log tree commit diff stats
path: root/tests/overload/tsystemcmp.nim
blob: aa761b75969e862f8561162aea4ccf71a4ceb09a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
discard """
  cmd: r"nim c --hints:on $options --threads:on $file"
  output: '''@["", "a", "ha", "hi", "ho", "huu"]'''
"""

import algorithm

# bug #1657
var modules = @["hi", "ho", "", "a", "ha", "huu"]
sort(modules, system.cmp)
echo modules

type
  MyType = object
    x: string

proc cmp(a, b: MyType): int = cmp(a.x, b.x)

var modulesB = @[MyType(x: "ho"), MyType(x: "ha")]
sort(modulesB, cmp)

# bug #2397

proc f(x: (proc(a,b: string): int) = system.cmp) = discard