hcl/t/insta-02.hcl

27 lines
633 B
HCL
Raw Normal View History

set t (
class | x | {
2024-02-03 09:50:10 +00:00
defun :* make() { set x 1234; return self; };
defun get-x() { return x };
}
);
set X t;
2024-01-18 14:55:50 +00:00
if (nqv? t X) { printf "ERROR: t must point to X\n" } \
else { printf "OK: t points to X\n" };
set t ((t:make):get-x);
2024-01-18 14:55:50 +00:00
if (nqv? t 1234) { printf "ERROR: t must be 1234\n" } \
else { printf "OK: t is %d\n" t };
set j #{ ((X:make):get-x): 9999, 4512: ((X: make): get-x) };
set v (dic.get j 1234);
2024-01-18 14:55:50 +00:00
if (nqv? v 9999) { printf "ERROR: v is not 9999\n" } \
else { printf "OK: value is %d\n" v };
set v (dic.get j 4512);
2024-01-18 14:55:50 +00:00
if (nqv? v 1234) { printf "ERROR: v is not 1234\n" } \
else { printf "OK: value is %d\n" v };