blob: 1a1d947b1cd1b3bf1715414d7e9b0b90590d9a94 (
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
25
26
27
28
29
30
31
|
discard """
output: '''obj has '==': false
int has '==': true
false
true
true
no'''
"""
# test the new 'compiles' feature:
template supports(opr, x: expr): bool {.immediate.} =
compiles(opr(x)) or compiles(opr(x, x))
type
TObj = object
var
myObj {.compileTime.}: TObj
echo "obj has '==': ", supports(`==`, myObj)
echo "int has '==': ", supports(`==`, 45)
echo supports(`++`, 34)
echo supports(`not`, true)
echo supports(`+`, 34)
when compiles(4+5.0 * "hallo"):
echo "yes"
else:
echo "no"
|