summary refs log tree commit diff stats
path: root/tests/concepts/tgraph.nim
blob: a0177a0430da57e4d8db262235196ea31c38f637 (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
discard """
  output: '''XY is Node
MyGraph is Graph'''
"""
# bug #3452
import math

type
    Node* = concept n
        `==`(n, n) is bool

    Graph* = concept g
        var x: Node
        distance(g, x, x) is float

    XY* = tuple[x, y: int]

    MyGraph* = object
        points: seq[XY]

if XY is Node:
    echo "XY is Node"

proc distance*( g: MyGraph, a, b: XY): float =
    sqrt( pow(float(a.x - b.x), 2) + pow(float(a.y - b.y), 2) )

if MyGraph is Graph:
    echo "MyGraph is Graph"
p">, req, "400 Test") resp := w.Result() if resp.StatusCode != http.StatusBadRequest { t.Errorf("Didn't receive 400, received: %v\n", resp.StatusCode) } }) } func Test_log404(t *testing.T) { initTestConf() t.Run("log404", func(t *testing.T) { w := httptest.NewRecorder() req := httptest.NewRequest("GET", "/404", nil) log404(w, req, errors.New("404 Test")) resp := w.Result() if resp.StatusCode != http.StatusNotFound { t.Errorf("Didn't receive 404, received: %v\n", resp.StatusCode) } }) } func Test_log500(t *testing.T) { initTestConf() t.Run("log500", func(t *testing.T) { w := httptest.NewRecorder() req := httptest.NewRequest("POST", "/500", nil) log500(w, req, errors.New("500 Test")) resp := w.Result() if resp.StatusCode != http.StatusInternalServerError { t.Errorf("Didn't receive 500, received: %v\n", resp.StatusCode) } }) }