emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
blob ba9119d581a6194c9f2b703c19bf10fafdd11ec6 5531 bytes (raw)
name: testing/examples/ob-haxe-test.org 	 # note: path name is non-authoritative(*)

  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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
 
#+Title: a collection of examples for ob-haxe tests
#+OPTIONS: ^:nil
* Simple
  :PROPERTIES:
  :ID:       966875e9-d10e-406c-9211-449555e3d3b2
  :END:
#+name: simple
#+begin_src haxe :results output silent
  Sys.print(42);
#+end_src

#+name: simple_with_main
#+begin_src haxe :results output silent
  static function main() {
      Sys.print(42);
  }
#+end_src

#+name: simple_with_public_main_interp
#+begin_src haxe :results output silent
  public static function main() {
      Sys.print(42);
  }
#+end_src

#+name: simple_with_public_main_neko
#+begin_src haxe :target neko :results output silent
  public static function main() {
      Sys.print(42);
  }
#+end_src

#+name: simple_with_public_main_hashlink
#+begin_src haxe :target hashlink :results output silent
  public static function main() {
      Sys.print(42);
  }
#+end_src

#+name: simple_with_class
#+begin_src haxe :results output silent
  class Simple {
      public static function main() {
          Sys.print(42);
      }
  }
#+end_src

#+name: simple_with_class_and_package
#+begin_src haxe :results output silent
  package pkg;
  class Simple {
      public static function main() {
          Sys.print(42);
      }
  }
#+end_src

#+name: simple_with_class_attr
#+begin_src haxe :results output silent :classname Simple
  public static function main() {
      Sys.print(42);
  }
#+end_src

#+name: simple_with_class_attr_with_package
#+begin_src haxe :results output silent :classname pkg.Simple
  public static function main() {
      Sys.print(42);
  }
#+end_src

* Variables
  :PROPERTIES:
  :ID:       ecbe8740-e254-4c53-84b2-21a61bf1afb4
  :END:

#+name: integer_var
#+begin_src haxe :var a=42 :results output silent
  Sys.print(a);
#+end_src

#+name: var_with_main
#+begin_src haxe :var a=42 :results output silent
  public static function main() {
      Sys.print(a);
  }
#+end_src

#+name: var_with_class
#+begin_src haxe :var a=42 :results output silent
  class Main {
    public static function main() {
        Sys.print(a);
    }
  }
#+end_src

#+name: var_with_class_and_package
#+begin_src haxe :var a=42 :results output silent
  package pkg;
  class Main {
    public static function main() {
        Sys.print(a);
    }
  }
#+end_src

#+name: var_with_class_and_hanging_curlies
#+begin_src haxe :var a=42 :results output silent
  class Main
  {
    public static function main()
    {
        Sys.print(a);
    }
  }
#+end_src

#+name: two_vars
#+begin_src haxe :var a=21 b=2 :results output silent
  Sys.print(a*b);
#+end_src

#+name: string_var
#+begin_src haxe :var a="forty two" :results output silent
  Sys.print('$a, len=${a.length}');
#+end_src

#+name: mulitline_string_var
#+begin_src haxe :var a="forty\ntwo" :results output silent
  Sys.print('$a, len=${a.length}');
#+end_src

* Array
  :PROPERTIES:
  :ID:       1e93864d-385b-4901-9d12-b566fdb5b813
  :END:

#+name: haxe_list
- forty
- two

#+name: return_vector
#+begin_src haxe :results vector silent
  return [[4], [2]];
#+end_src

#+name: read_return_list
#+begin_src haxe :var a=haxe_list :results silent
  return [a[0][0], a[1][0]];
#+end_src

this is not an interesting test, but it demonstrates how to use
~:results output~ to write a neatly formatted list of strings which
can include spaces.

#+name: read_output_list
#+begin_src haxe :var a=haxe_list :results output list raw silent
  Sys.println('forty two');
  Sys.println('forty two');
#+end_src

* Matrix
  :PROPERTIES:
  :ID:       a93bb906-eef8-4089-b490-64f266f5696c
  :END:
#+name: haxe_matrix
| 2 | 1 |
| 4 | 2 |

#+name: list_var
#+begin_src haxe :var a='("forty" "two") :results silent
  return [a[0], a[1]];
#+end_src

#+name: vector_var
#+begin_src haxe :var a='["forty" "two"] :results silent
    return [a[0], a[1]];
#+end_src

#+name: matrix_var
#+begin_src haxe :var a=haxe_matrix :results silent
  return [[a[0][0], a[1][0]], // transpose
          [a[0][1], a[1][1]]];
#+end_src

#+name: matrix_var_with_header
#+begin_src haxe :var a=haxe_matrix :results value table silent
  return [["col1","col2"],
          null,
          [a[0][0], a[1][0]], // transpose
          [a[0][1], a[1][1]]];
#+end_src

this is not an interesting test, but it demonstrates how to use
~:results output~ to write a table with header.

#+name: output_table_with_header
#+begin_src haxe :var a=haxe_matrix :results output raw table silent
  Sys.println("|col1|col2|");
  Sys.println("|-");
  for (ii in 0...a.length) {
      for (jj in 0...a[0].length) {
          Sys.print('|${a[ii][jj]}');
      }
      Sys.println("");
   }
#+end_src

* Inhomogeneous Table
  :PROPERTIES:
  :ID:       192cbb7d-9038-47ca-bab3-a0cbf44b487d
  :END:

#+name: haxe_table
  | string | number |
  |--------+--------|
  | forty  |      2 |
  | two    |      1 |

#+name: inhomogeneous_table
#+begin_src haxe :var a=haxe_table :results silent
  return [[a[0][0], a[0][1]*2],
          [a[1][0], a[1][1]*2]];
#+end_src

* Library
  :PROPERTIES:
  :ID:       0b945cde-55a1-4723-8d78-5f69d98d09fa
  :END:

#+name: import_library
#+begin_src haxe :results output silent :imports haxe.crypto.Base64 haxe.io.Bytes
  var encoded = Base64.encode(Bytes.ofString("42"));
  var decoded = Base64.decode(encoded);
  Sys.print('encoded=$encoded, decoded=$decoded');
#+end_src

#+name: import_library_inline
#+begin_src haxe :results output silent
  import haxe.crypto.Base64;
  import haxe.io.Bytes;
  var encoded = Base64.encode(Bytes.ofString("42"));
  var decoded = Base64.decode(encoded);
  Sys.print('encoded=$encoded, decoded=$decoded');
#+end_src

debug log:

solving ba9119d58 ...
found ba9119d58 in https://list.orgmode.org/orgmode/CAC=rjb6FnA=WuMK_qfto=rFfH=QZHet_-7AXd26NQ-Ktjd5y8w@mail.gmail.com/

applying [1/1] https://list.orgmode.org/orgmode/CAC=rjb6FnA=WuMK_qfto=rFfH=QZHet_-7AXd26NQ-Ktjd5y8w@mail.gmail.com/
diff --git a/testing/examples/ob-haxe-test.org b/testing/examples/ob-haxe-test.org
new file mode 100644
index 000000000..ba9119d58

Checking patch testing/examples/ob-haxe-test.org...
Applied patch testing/examples/ob-haxe-test.org cleanly.

index at:
100644 ba9119d581a6194c9f2b703c19bf10fafdd11ec6	testing/examples/ob-haxe-test.org

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).