aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/extension.lux
blob: 450570c20973da0f77376b78b55cf7575937fcc3 (plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
(.module:
  [lux #*
   ["." debug]
   ["@" target
    ["." jvm]
    ["." js]
    ["." python]
    ["." lua]
    ["." ruby]]
   [abstract
    [monad (#+ do)]]
   [control
    ["." try]
    ["<>" parser
     ["<c>" code]
     ["<a>" analysis]
     ["<s>" synthesis]]]
   [data
    ["." text ("#\." equivalence)
     ["%" format (#+ format)]]
    [collection
     ["." row]]]
   [tool
    [compiler
     ["." phase]
     [language
      [lux
       ["." analysis]
       ["." synthesis]
       ["." directive]
       [phase
        [analysis
         ["." type]]]]]]]
   ["_" test (#+ Test)]]
  {1
   ["." / (#+ analysis: synthesis: generation: directive:)]})

(def: my_analysis "my analysis")
(def: my_synthesis "my synthesis")
(def: my_generation "my generation")
(def: my_directive "my directive")

## Generation
(for {@.old
      (as_is)}
     
     (as_is (analysis: (..my_generation self phase archive {parameters (<>.some <c>.any)})
              (do phase.monad
                [_ (type.infer .Text)]
                (wrap (#analysis.Extension self (list)))))

            (synthesis: (..my_generation self phase archive {parameters (<>.some <a>.any)})
              (do phase.monad
                []
                (wrap (#synthesis.Extension self (list)))))
            ))

(for {@.old
      (as_is)}
     
     (generation: (..my_generation self phase archive {parameters (<>.some <s>.any)})
       (do phase.monad
         []
         (wrap (for {@.jvm
                     (row.row (#jvm.Constant (#jvm.LDC (#jvm.String self))))

                     @.js (js.string self)
                     @.python (python.unicode self)
                     @.lua (lua.string self)
                     @.ruby (ruby.string self)})))))

(for {@.old
      (as_is)}
     
     (as_is (analysis: (..my_analysis self phase archive {parameters (<>.some <c>.any)})
              (do phase.monad
                [_ (type.infer .Text)]
                (wrap (#analysis.Primitive (#analysis.Text self)))))

            ## Synthesis
            (analysis: (..my_synthesis self phase archive {parameters (<>.some <c>.any)})
              (do phase.monad
                [_ (type.infer .Text)]
                (wrap (#analysis.Extension self (list)))))

            (synthesis: (..my_synthesis self phase archive {parameters (<>.some <a>.any)})
              (do phase.monad
                []
                (wrap (synthesis.text self))))
            
            ## Directive
            (directive: (..my_directive self phase archive {parameters (<>.some <c>.any)})
              (do phase.monad
                [#let [_ (debug.log! (format "Successfully installed directive " (%.text self) "!"))]]
                (wrap directive.no_requirements)))

            (`` ((~~ (static ..my_directive))))
            ))

(def: #export test
  Test
  (<| (_.covering /._)
      (`` ($_ _.and
              (~~ (template [<macro> <extension>]
                    [(_.cover [<macro>]
                              (for {@.old
                                    false}
                                   (text\= (`` ((~~ (static <extension>))))
                                           <extension>)))]

                    [/.analysis: ..my_analysis]
                    [/.synthesis: ..my_synthesis]
                    [/.generation: ..my_generation]))
              (_.cover [/.directive:]
                       true)
              ))))