OILS / stdlib / ysh / def-test.ysh View on Github | oilshell.org

43 lines, 27 significant
1use $LIB_YSH/def.ysh --pick Dict
2
3: ${LIB_OSH=stdlib/osh}
4source $LIB_OSH/byo-server.sh
5
6proc test-dict {
7 var i = 0
8 Dict (&d) {
9 a = 42
10 b = i + 1
11 }
12 pp test_ (d)
13}
14
15
16func Counter(start) {
17 ### constructor
18 var methods = Object(null, Counter_methods)
19 return (Object(methods, {i: start}))
20}
21
22var Counter_methods = null
23
24# BUG: I think there is a problem with using Dict in a DIFFERENT module!
25
26if false {
27Dict (&Counter_methods) {
28 #func inc(self, n) {
29 # setvar self.i += n
30 #}
31 i = 2
32}
33}
34
35proc test-class-pattern {
36 #var c = Counter(5)
37 #call c.inc(5)
38 :
39}
40
41if is-main {
42 byo-maybe-run
43}