|
1 | 1 | (defmodule unit-kla-tests
|
2 | 2 | (behaviour ltest-unit)
|
3 |
| - (export all) |
4 |
| - (import |
5 |
| - (from ltest |
6 |
| - (check-failed-assert 2) |
7 |
| - (check-wrong-assert-exception 2)))) |
| 3 | + (export all)) |
8 | 4 |
|
9 | 5 | (include-lib "ltest/include/ltest-macros.lfe")
|
10 | 6 |
|
11 |
| -(deftest my-adder |
12 |
| - (is-equal 4 (: kla my-adder 2 2))) |
| 7 | +(deftest -replace-dash |
| 8 | + (is-equal "has_dash" (kla:-replace-dash "has-dash")) |
| 9 | + (is-equal "has_underscore" (kla:-replace-dash "has_underscore")) |
| 10 | + (is-equal "neither" (kla:-replace-dash "neither"))) |
| 11 | + |
| 12 | +(deftest replace-dash-string |
| 13 | + (is-equal "has_dash" (kla:replace-dash "has-dash")) |
| 14 | + (is-equal "has_underscore" (kla:replace-dash "has_underscore")) |
| 15 | + (is-equal "neither" (kla:replace-dash "neither"))) |
| 16 | + |
| 17 | +(deftest replace-dash-atom |
| 18 | + (is-equal 'has_dash (kla:replace-dash 'has-dash)) |
| 19 | + (is-equal 'has_underscore (kla:replace-dash 'has_underscore)) |
| 20 | + (is-equal 'neither (kla:replace-dash 'neither))) |
| 21 | + |
| 22 | +(deftest append-integer-string |
| 23 | + (is-equal "a1" (kla:append-integer "a" 1)) |
| 24 | + (is-equal "abc1" (kla:append-integer "abc" 1)) |
| 25 | + (is-equal "abc100" (kla:append-integer "abc" 100)) |
| 26 | + (is-equal "abc1001" (kla:append-integer "abc" 1001)) |
| 27 | + (is-equal "abc1" (kla:append-integer "abc" 001))) |
| 28 | + |
| 29 | +(deftest append-integer-atom |
| 30 | + (is-equal 'a1 (kla:append-integer 'a 1)) |
| 31 | + (is-equal 'abc1 (kla:append-integer 'abc 1)) |
| 32 | + (is-equal 'abc100 (kla:append-integer 'abc 100)) |
| 33 | + (is-equal 'abc1001 (kla:append-integer 'abc 1001)) |
| 34 | + (is-equal 'abc1 (kla:append-integer 'abc 001))) |
| 35 | + |
| 36 | +(deftest append-integer-integer |
| 37 | + (is-equal "11" (kla:append-integer 1 1)) |
| 38 | + (is-equal "2001" (kla:append-integer 200 1)) |
| 39 | + (is-equal "200100" (kla:append-integer 200 100)) |
| 40 | + (is-equal "2001001" (kla:append-integer 200 1001)) |
| 41 | + (is-equal "21" (kla:append-integer 002 001))) |
| 42 | + |
| 43 | +(deftest make-args |
| 44 | + (is-equal '() (kla:make-args 0)) |
| 45 | + (is-equal '(arg-1) (kla:make-args 1)) |
| 46 | + (is-equal '(arg-1 arg-2) (kla:make-args 2)) |
| 47 | + (is-equal '(arg-1 arg-2 arg-3 arg-4) (kla:make-args 4))) |
| 48 | + |
| 49 | +(deftest make-func |
| 50 | + (is-equal |
| 51 | + '(defun my-func-name () |
| 52 | + (apply 'mod-1 'my_func_name (list ))) |
| 53 | + (kla:make-func '(my-func-name 0) 'mod-1)) |
| 54 | + (is-equal |
| 55 | + '(defun my-func-name (arg-1) |
| 56 | + (apply 'mod-2 'my_func_name (list arg-1))) |
| 57 | + (kla:make-func '(my-func-name 1) 'mod-2)) |
| 58 | + (is-equal |
| 59 | + '(defun my-func-name (arg-1 arg-2) |
| 60 | + (apply 'mod-3 'my_func_name (list arg-1 arg-2))) |
| 61 | + (kla:make-func '(my-func-name 2) 'mod-3))) |
| 62 | + |
| 63 | +(deftest make-funcs |
| 64 | + (is-equal |
| 65 | + '((defun func-y () |
| 66 | + (apply 'my-mod 'func_y (list))) |
| 67 | + (defun func-y (arg-1) |
| 68 | + (apply 'my-mod 'func_y (list arg-1))) |
| 69 | + (defun func-y (arg-1 arg-2) |
| 70 | + (apply 'my-mod 'func_y (list arg-1 arg-2)))) |
| 71 | + (kla:make-funcs '((func-y 0) (func-y 1) (func-y 2)) 'my-mod))) |
0 commit comments