nadesiko3 3.2.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (283) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +107 -0
  3. package/bin/cnako3 +10 -0
  4. package/bin/cnako3.bat +11 -0
  5. package/bin/nako3server.bat +6 -0
  6. package/demo/ace_editor.html +90 -0
  7. package/demo/ace_editor_tabs.html +162 -0
  8. package/demo/basic.html +71 -0
  9. package/demo/browsers.html +128 -0
  10. package/demo/css/basic.css +3 -0
  11. package/demo/css/common.css +157 -0
  12. package/demo/css/editor.css +8 -0
  13. package/demo/css/flow.css +3 -0
  14. package/demo/css/index.css +3 -0
  15. package/demo/extlib/ace@1.4.12/ace.js +17 -0
  16. package/demo/extlib/ace@1.4.12/ext-code_lens.min.js +1 -0
  17. package/demo/extlib/ace@1.4.12/ext-language_tools.min.js +1 -0
  18. package/demo/extlib/ace@1.4.12/ext-options.min.js +1 -0
  19. package/demo/extlib/ace@1.4.12/ext-settings_menu.js +8 -0
  20. package/demo/extlib/ace@1.4.12/keybinding-vscode.js +8 -0
  21. package/demo/extlib/ace@1.4.12/theme-monokai.js +8 -0
  22. package/demo/extlib/ace@1.4.12/theme-xcode.js +8 -0
  23. package/demo/extlib/chart.js@3.2.1/chart.min.js +13 -0
  24. package/demo/extlib/pure-min.css +11 -0
  25. package/demo/flow.html +97 -0
  26. package/demo/graph.html +53 -0
  27. package/demo/image/nako.png +0 -0
  28. package/demo/image/nakopad-icon256.png +0 -0
  29. package/demo/image/turtle.fla +0 -0
  30. package/demo/image/turtle.png +0 -0
  31. package/demo/index.html +134 -0
  32. package/demo/js/common.js +17 -0
  33. package/demo/js/turtle3d_test.js +44 -0
  34. package/demo/js/turtle_test.js +44 -0
  35. package/demo/runscript.html +47 -0
  36. package/demo/runscript2.html +33 -0
  37. package/demo/turtle.html +58 -0
  38. package/demo/turtle2.html +141 -0
  39. package/demo/turtle3.html +278 -0
  40. package/demo/turtle3d.html +58 -0
  41. package/demo/turtle3d2.html +107 -0
  42. package/demo/version.html +24 -0
  43. package/doc/SETUP.md +172 -0
  44. package/doc/about.md +34 -0
  45. package/doc/browsers.md +60 -0
  46. package/doc/docgen.md +21 -0
  47. package/doc/editor.md +44 -0
  48. package/doc/files.md +37 -0
  49. package/doc/plugins.md +195 -0
  50. package/doc/release.md +78 -0
  51. package/doc/win32.md +57 -0
  52. package/package.json +196 -0
  53. package/release/_hash.txt +65 -0
  54. package/release/_script-tags.txt +13 -0
  55. package/release/command.json +1 -0
  56. package/release/command.json.js +1 -0
  57. package/release/command_cnako3.json +1 -0
  58. package/release/command_list.json +1 -0
  59. package/release/editor.js +2 -0
  60. package/release/editor.js.LICENSE.txt +32 -0
  61. package/release/josi.json +48 -0
  62. package/release/nako_gen_async.js +1 -0
  63. package/release/nako_gen_async.js.LICENSE.txt +595 -0
  64. package/release/plugin_caniuse.js +1 -0
  65. package/release/plugin_caniuse.js.LICENSE.txt +411 -0
  66. package/release/plugin_csv.js +1 -0
  67. package/release/plugin_csv.js.LICENSE.txt +367 -0
  68. package/release/plugin_datetime.js +1 -0
  69. package/release/plugin_datetime.js.LICENSE.txt +471 -0
  70. package/release/plugin_kansuji.js +1 -0
  71. package/release/plugin_kansuji.js.LICENSE.txt +491 -0
  72. package/release/plugin_markup.js +1 -0
  73. package/release/plugin_markup.js.LICENSE.txt +363 -0
  74. package/release/plugin_turtle.js +1 -0
  75. package/release/plugin_turtle.js.LICENSE.txt +435 -0
  76. package/release/plugin_webworker.js +1 -0
  77. package/release/plugin_webworker.js.LICENSE.txt +491 -0
  78. package/release/version.js +2 -0
  79. package/release/version.js.LICENSE.txt +32 -0
  80. package/release/wnako3.js +2 -0
  81. package/release/wnako3.js.LICENSE.txt +1 -0
  82. package/release/wnako3webworker.js +1 -0
  83. package/release/wnako3webworker.js.LICENSE.txt +847 -0
  84. package/release/yoyakugo.json +30 -0
  85. package/src/browsers.md +60 -0
  86. package/src/cnako3.js +466 -0
  87. package/src/commander_ja.js +154 -0
  88. package/src/enako3.js +69 -0
  89. package/src/era.json +22 -0
  90. package/src/index.js +5 -0
  91. package/src/nako3.js +836 -0
  92. package/src/nako3_assert.js +37 -0
  93. package/src/nako3editorfix.sfd +106 -0
  94. package/src/nako3editorfix.woff +0 -0
  95. package/src/nako3server.js +51 -0
  96. package/src/nako_colors.js +86 -0
  97. package/src/nako_errors.js +176 -0
  98. package/src/nako_gen.js +1459 -0
  99. package/src/nako_gen_async.js +1622 -0
  100. package/src/nako_global.js +113 -0
  101. package/src/nako_indent.js +480 -0
  102. package/src/nako_josi_list.js +46 -0
  103. package/src/nako_lex_rules.js +259 -0
  104. package/src/nako_lexer.js +576 -0
  105. package/src/nako_logger.js +138 -0
  106. package/src/nako_parser3.js +1768 -0
  107. package/src/nako_parser_base.js +265 -0
  108. package/src/nako_parser_const.js +37 -0
  109. package/src/nako_prepare.js +293 -0
  110. package/src/nako_reserved_words.js +35 -0
  111. package/src/nako_source_mapping.js +251 -0
  112. package/src/nako_test.js +37 -0
  113. package/src/nako_version.js +8 -0
  114. package/src/plugin_browser.js +191 -0
  115. package/src/plugin_browser_ajax.js +352 -0
  116. package/src/plugin_browser_audio.js +109 -0
  117. package/src/plugin_browser_canvas.js +462 -0
  118. package/src/plugin_browser_chart.js +296 -0
  119. package/src/plugin_browser_color.js +49 -0
  120. package/src/plugin_browser_crypto.js +26 -0
  121. package/src/plugin_browser_dialog.js +53 -0
  122. package/src/plugin_browser_dom_basic.js +322 -0
  123. package/src/plugin_browser_dom_event.js +193 -0
  124. package/src/plugin_browser_dom_parts.js +163 -0
  125. package/src/plugin_browser_geolocation.js +51 -0
  126. package/src/plugin_browser_hotkey.js +25 -0
  127. package/src/plugin_browser_html.js +59 -0
  128. package/src/plugin_browser_in_worker.js +44 -0
  129. package/src/plugin_browser_location.js +21 -0
  130. package/src/plugin_browser_speech.js +111 -0
  131. package/src/plugin_browser_storage.js +121 -0
  132. package/src/plugin_browser_system.js +12 -0
  133. package/src/plugin_browser_websocket.js +73 -0
  134. package/src/plugin_caniuse.js +24 -0
  135. package/src/plugin_csv.js +57 -0
  136. package/src/plugin_datetime.js +414 -0
  137. package/src/plugin_express.js +212 -0
  138. package/src/plugin_kansuji.js +224 -0
  139. package/src/plugin_keigo.js +55 -0
  140. package/src/plugin_markup.js +32 -0
  141. package/src/plugin_math.js +319 -0
  142. package/src/plugin_node.js +1018 -0
  143. package/src/plugin_promise.js +94 -0
  144. package/src/plugin_system.js +2109 -0
  145. package/src/plugin_test.js +38 -0
  146. package/src/plugin_turtle.js +646 -0
  147. package/src/plugin_webworker.js +334 -0
  148. package/src/plugin_weykturtle3d.js +1216 -0
  149. package/src/plugin_worker.js +92 -0
  150. package/src/repl.nako3 +63 -0
  151. package/src/turtle-elephant.png +0 -0
  152. package/src/turtle-panda.png +0 -0
  153. package/src/turtle64.png +0 -0
  154. package/src/wnako3.js +162 -0
  155. package/src/wnako3_editor.css +215 -0
  156. package/src/wnako3_editor.js +1645 -0
  157. package/src/wnako3_editor_marker_red.png +0 -0
  158. package/src/wnako3_editor_marker_red.xcf +0 -0
  159. package/src/wnako3_editor_marker_yellow.png +0 -0
  160. package/src/wnako3_editor_marker_yellow.xcf +0 -0
  161. package/src/wnako3webworker.js +70 -0
  162. package/test/ace_editor/karma.config.js +94 -0
  163. package/test/ace_editor/test/.babelrc.json +3 -0
  164. package/test/ace_editor/test/ace_editor_test.js +178 -0
  165. package/test/ace_editor/test/html/custom_context.html +140 -0
  166. package/test/async/async_basic_test.js +124 -0
  167. package/test/browser/karma.config.js +212 -0
  168. package/test/browser/test/.babelrc.json +3 -0
  169. package/test/browser/test/compare_util.js +50 -0
  170. package/test/browser/test/html/canvas_basic.html +1 -0
  171. package/test/browser/test/html/div_basic.html +2 -0
  172. package/test/browser/test/html/event_dom_form.html +4 -0
  173. package/test/browser/test/html/event_dom_scrolldiv.html +5 -0
  174. package/test/browser/test/image/canvas_test1.png +0 -0
  175. package/test/browser/test/image/canvas_test2.png +0 -0
  176. package/test/browser/test/image/canvas_test3.png +0 -0
  177. package/test/browser/test/image/canvas_test4.png +0 -0
  178. package/test/browser/test/image/canvas_test7.png +0 -0
  179. package/test/browser/test/image/canvas_test8.png +0 -0
  180. package/test/browser/test/image/canvas_test_blank.png +0 -0
  181. package/test/browser/test/image/elephant_kana.png +0 -0
  182. package/test/browser/test/image/panda_kana.png +0 -0
  183. package/test/browser/test/image/turtle_kana.png +0 -0
  184. package/test/browser/test/import_plugin_checker.js +24 -0
  185. package/test/browser/test/plugin_browser_test.js +52 -0
  186. package/test/browser/test/plugin_browser_test_ajax.js +123 -0
  187. package/test/browser/test/plugin_browser_test_color.js +18 -0
  188. package/test/browser/test/plugin_browser_test_dialog.js +72 -0
  189. package/test/browser/test/plugin_browser_test_dom_event.js +598 -0
  190. package/test/browser/test/plugin_browser_test_dom_parts.js +125 -0
  191. package/test/browser/test/plugin_browser_test_system.js +9 -0
  192. package/test/browser/test/plugin_turtle_test.js +817 -0
  193. package/test/browser/test/plugin_webworker_test.js +87 -0
  194. package/test/browser/test/require_test.js +71 -0
  195. package/test/bundled/karma.config.base.js +117 -0
  196. package/test/bundled/karma.config.js +86 -0
  197. package/test/bundled/test/.babelrc.json +3 -0
  198. package/test/bundled/test/bundled_test.js +69 -0
  199. package/test/bundled/test/html/custom_context.html +65 -0
  200. package/test/bundled/test/html/custom_debug.html +66 -0
  201. package/test/bundled/test4b.cmd +52 -0
  202. package/test/bundled/test_base/.babelrc.json +3 -0
  203. package/test/bundled/test_base/_checktool_test.js +25 -0
  204. package/test/bundled/test_base/basic_ajax_test.js +56 -0
  205. package/test/bundled/test_base/basic_async_test.js +18 -0
  206. package/test/bundled/test_base/basic_test.js +153 -0
  207. package/test/bundled/test_base/calc_test.js +132 -0
  208. package/test/bundled/test_base/css/browsers_box.css +114 -0
  209. package/test/bundled/test_base/html/custom_context.html +69 -0
  210. package/test/bundled/test_base/html/custom_debug.html +71 -0
  211. package/test/bundled/test_base/js/browsers_box.js +72 -0
  212. package/test/bundled/test_base/plugin_csv_test.js +37 -0
  213. package/test/bundled/test_base/plugin_datetime_test.js +115 -0
  214. package/test/bundled/test_base/plugin_kansuji_test.js +49 -0
  215. package/test/bundled/test_base/plugin_system_test.js +410 -0
  216. package/test/bundled/test_base/plugin_webworker_test.js +53 -0
  217. package/test/bundled/test_base/resources/ok.txt +1 -0
  218. package/test/bundled/test_base/test_utils.js +191 -0
  219. package/test/common/array_test.js +40 -0
  220. package/test/common/basic_test.js +317 -0
  221. package/test/common/calc_test.js +139 -0
  222. package/test/common/debug_test.js +16 -0
  223. package/test/common/error_test.js +16 -0
  224. package/test/common/flow_test.js +360 -0
  225. package/test/common/func_call.js +136 -0
  226. package/test/common/func_test.js +149 -0
  227. package/test/common/indent_test.js +362 -0
  228. package/test/common/lex_test.js +146 -0
  229. package/test/common/literal_test.js +72 -0
  230. package/test/common/nako_logger_test.js +26 -0
  231. package/test/common/plugin_browser_test.js +24 -0
  232. package/test/common/plugin_browser_ut_audio_test.js +88 -0
  233. package/test/common/plugin_browser_ut_color_test.js +21 -0
  234. package/test/common/plugin_browser_ut_dialog_test.js +100 -0
  235. package/test/common/plugin_browser_ut_html_test.js +13 -0
  236. package/test/common/plugin_browser_ut_system_test.js +10 -0
  237. package/test/common/plugin_csv_test.js +39 -0
  238. package/test/common/plugin_datetime_test.js +120 -0
  239. package/test/common/plugin_kansuji_test.js +59 -0
  240. package/test/common/plugin_promise_test.js +18 -0
  241. package/test/common/plugin_system_test.js +451 -0
  242. package/test/common/prepare_test.js +93 -0
  243. package/test/common/re_test.js +20 -0
  244. package/test/common/variable_scope_test.js +105 -0
  245. package/test/jsconfig.json +19 -0
  246. package/test/karma.config.js +91 -0
  247. package/test/node/add_test.nako3 +1 -0
  248. package/test/node/async_test.js +80 -0
  249. package/test/node/commander_ja_test.js +82 -0
  250. package/test/node/error_message_test.js +244 -0
  251. package/test/node/kai_test.nako3 +6 -0
  252. package/test/node/node_test.js +43 -0
  253. package/test/node/plugin_broken.js.txt +3 -0
  254. package/test/node/plugin_browser_ut_ajax_test.js +355 -0
  255. package/test/node/plugin_browser_ut_location_test.js +32 -0
  256. package/test/node/plugin_markup_test.js +44 -0
  257. package/test/node/plugin_math_test.js +42 -0
  258. package/test/node/plugin_node_test.js +93 -0
  259. package/test/node/plugin_test.js +16 -0
  260. package/test/node/relative_import_test_1.nako3 +1 -0
  261. package/test/node/relative_import_test_2.nako3 +2 -0
  262. package/test/node/require_nako3_test.js +59 -0
  263. package/test/node/requiretest.nako3 +4 -0
  264. package/test/node/requiretest_indirect.nako3 +1 -0
  265. package/test/node/requiretest_name.nako3 +5 -0
  266. package/test/node/runtime_error.nako3 +2 -0
  267. package/test/node/side_effects_test.js +106 -0
  268. package/test/node/sjis.txt +5 -0
  269. package/test/node/syntax_error.nako3 +2 -0
  270. package/test/node/wnako3_editor_test.js +360 -0
  271. package/tools/README.md +7 -0
  272. package/tools/nako3edit/html/edit.html +83 -0
  273. package/tools/nako3edit/html/edit_plugin.js +6 -0
  274. package/tools/nako3edit/html/files.html +49 -0
  275. package/tools/nako3edit/html/nako3edit.css +66 -0
  276. package/tools/nako3edit/index.nako3 +145 -0
  277. package/tools/nako3edit/run.js +12 -0
  278. package/tools/nako3server/html/edit.html +104 -0
  279. package/tools/nako3server/html/edit_plugin.js +6 -0
  280. package/tools/nako3server/html/files.html +53 -0
  281. package/tools/nako3server/html/nako3edit.css +66 -0
  282. package/tools/nako3server/index.nako3 +129 -0
  283. package/tools/nako3server/run.js +12 -0
@@ -0,0 +1,87 @@
1
+ import 'whatwg-fetch'
2
+ import { assert } from 'chai'
3
+ import NakoCompiler from 'nako3/nako3.js'
4
+ import PluginBrowser from 'nako3/plugin_browser'
5
+ import { importStatus } from './import_plugin_checker.js'
6
+ import PluginWebWorker from 'nako3/plugin_webworker'
7
+ import { retry } from './compare_util'
8
+
9
+ describe('plugin_webworker_test', () => {
10
+ let nako = null
11
+ afterEach(() => {
12
+ nako = null
13
+ })
14
+ beforeEach(() => {
15
+ nako = new NakoCompiler()
16
+ // const pluginClone = Object.assign({}, PluginWebWorker)
17
+ // nako.addPluginFile('PluginWebWorker', 'plugin_webworker.js', pluginClone)
18
+ nako.addPluginFile('PluginBrowser', 'plugin_browser.js', PluginBrowser)
19
+ nako.addPluginFile('PluginWebWorker', 'plugin_webworker.js', PluginWebWorker)
20
+ })
21
+
22
+ // --- test ---
23
+ it('auto import for browser', () => {
24
+ const pluginName = 'PluginWebWorker'
25
+ const imported = importStatus.hasImport(pluginName)
26
+ assert.ok(imported, 'was import')
27
+ const autoImport = importStatus.getAutoImport(pluginName)
28
+ assert.strictEqual(typeof (autoImport.obj), 'object')
29
+ })
30
+
31
+ it('web worker basic', async () => {
32
+ const msgs = []
33
+ nako.addFunc('報告', [['を']], (msg) => {
34
+ msgs.push(msg)
35
+ })
36
+ const code = `Wは「/wnako3webworker.js」をワーカー起動
37
+ WにNAKOワーカーハンドラ設定
38
+ WからNAKOワーカーデータ受信した時には、
39
+  受信データを報告
40
+  Wをワーカー終了
41
+ ここまで
42
+ WからNAKOワーカー表示した時には、
43
+  受信データを報告
44
+ ここまで
45
+
46
+ Wで「"かかかかか"を表示する;"<>?"をHTML変換して表示する;"おわり"をNAKOワーカーデータ送信」をNAKOワーカープログラム起動
47
+ `
48
+ nako.run(code)
49
+
50
+ await retry(() => assert.equal(JSON.stringify(msgs), '["かかかかか","&lt;&gt;?","おわり"]'))
51
+ }).timeout(10000)
52
+
53
+ it('web worker transport', async () => {
54
+ const msgs = []
55
+ nako.addFunc('報告', [['を']], (msg) => {
56
+ msgs.push(msg)
57
+ })
58
+ const code = `Wは「/wnako3webworker.js」をワーカー起動
59
+ WにNAKOワーカーハンドラ設定
60
+ WからNAKOワーカーデータ受信した時には、
61
+  受信データを報告
62
+  WをNAKOワーカー終了
63
+ ここまで
64
+ WからNAKOワーカー表示した時には、
65
+  受信データを報告
66
+ ここまで
67
+
68
+ ワーカー側値は「おわり」
69
+ ●ワーカ内処理とは
70
+  NAKOワーカーデータ受信した時には、
71
+   受信データを表示
72
+   「<>?」をHTML変換して表示する
73
+   ワーカー側値をNAKOワーカーデータ送信
74
+  ここまで
75
+ ここまで
76
+
77
+ Wに["ワーカ内処理","ワーカー側値"]をNAKOワーカー転送
78
+ ワーカー側値は「始まり」
79
+
80
+ Wで「ワーカ内処理する」をNAKOワーカープログラム起動
81
+ Wに「あいうえお」をNAKOワーカーデータ送信
82
+ `
83
+ nako.run(code)
84
+
85
+ await retry(() => assert.equal(JSON.stringify(msgs), '["あいうえお","&lt;&gt;?","おわり"]'))
86
+ }).timeout(10000)
87
+ })
@@ -0,0 +1,71 @@
1
+ import { assert } from 'chai'
2
+ import { NakoImportError } from 'nako3/nako_errors'
3
+
4
+ navigator.exportWNako3 = true
5
+ const WebNakoCompiler = require('nako3/wnako3')
6
+ navigator.exportWNako3 = false
7
+
8
+ /**
9
+ * @param {'nako3' | 'js'} ext
10
+ * @param {number} delayMs
11
+ * @param {string} content
12
+ */
13
+ const buildURL = (ext, delayMs, content) => `http://localhost:9876/custom/echo.${ext}?delay_ms=${delayMs}&content=${encodeURIComponent(content)}`
14
+
15
+ describe('require_test', () => {
16
+ it('なでしこ言語ファイルの取り込み', async () => {
17
+ const nako = new WebNakoCompiler()
18
+ const code = `!「${buildURL('nako3', 0, 'A=100')}」を取り込む。\nAを表示`
19
+ await nako.loadDependencies(code, 'main.nako3')
20
+ assert.strictEqual(nako.run(code, 'main.nako3').log, '100')
21
+ })
22
+ it('循環インポート', async () => {
23
+ const nako = new WebNakoCompiler()
24
+ const code = `!「http://localhost:9876/custom/cyclic_import_1.nako3」を取り込む。\nAを表示\nBを表示`
25
+ await nako.loadDependencies(code, 'main.nako3')
26
+ assert.strictEqual(nako.run(code, 'main.nako3').log, '100\n200')
27
+ })
28
+ it('並列ダウンロード', async () => {
29
+ // 遅延が100msのファイルを2つ取り込んで、取り込みにかかる時間が200ms未満であることを確認する。
30
+ const nako = new WebNakoCompiler()
31
+ const fileA = buildURL('nako3', 100, 'A=100')
32
+ const fileB = buildURL('nako3', 100, 'B=200')
33
+ const startTime = Date.now()
34
+ const code = `!「${fileA}」を取り込む。!「${fileB}」を取り込む。\nAを表示\nBを表示`
35
+ await nako.loadDependencies(code, 'main.nako3')
36
+ assert.ok(Date.now() - startTime < 200)
37
+ assert.strictEqual(nako.run(code, 'main.nako3').log, '100\n200')
38
+ })
39
+ it('プラグインの取り込み', async () => {
40
+ const nako = new WebNakoCompiler()
41
+ const code =
42
+ `!「${buildURL('js', 0, `navigator.nako3.addPluginObject('PluginRequireTest', { requiretest: { type: 'var', value: 100 } })`)}」を取り込む。\n` +
43
+ 'requiretestを表示\n'
44
+ await nako.loadDependencies(code, 'main.nako3')
45
+ assert.strictEqual(nako.run(code, 'main.nako3').log, '100')
46
+ })
47
+ it('存在しないファイルの指定', async () => {
48
+ const nako = new WebNakoCompiler()
49
+ const code = `!「${buildURL('nako3', 50, 'A=100')}」を取り込む。\n!「http://localhost:9876/custom/non_existent_file.nako3」を取り込む。`
50
+ try {
51
+ await nako.loadDependencies(code, 'main.nako3')
52
+ assert.fail()
53
+ } catch (e) {
54
+ assert(e instanceof NakoImportError)
55
+ assert.strictEqual(e.line, 1)
56
+ }
57
+ })
58
+ it('.jsファイルの投げたエラーを表示', async () => {
59
+ const nako = new WebNakoCompiler()
60
+ const code = `!「${buildURL('js', 0, `throw new Error("テスト"); navigator.nako3.addPluginObject('PluginRequireTest', {})`)}」を取り込む。`
61
+ await nako.loadDependencies(code, 'main.nako3')
62
+ try {
63
+ nako.run(code, 'main.nako3')
64
+ assert.fail()
65
+ } catch (err) {
66
+ assert(err instanceof NakoImportError)
67
+ assert.include(err.message, "テスト")
68
+ assert.strictEqual(err.line, 0)
69
+ }
70
+ })
71
+ })
@@ -0,0 +1,117 @@
1
+ const path = require('path')
2
+
3
+ module.exports = function (config) {
4
+ config.set({
5
+ basePath: '',
6
+ urlRoot: '/',
7
+ frameworks: ['chai', 'mocha', 'webpack'],
8
+ files: [
9
+ 'test_base/*_test.js',
10
+ {
11
+ pattern: '../../release/*.js',
12
+ included: false,
13
+ served: true,
14
+ watched: false,
15
+ nocache: true
16
+ },
17
+ {
18
+ pattern: 'test_base/js/*.js',
19
+ included: false,
20
+ served: true,
21
+ watched: false,
22
+ nocache: true
23
+ },
24
+ {
25
+ pattern: 'test_base/resources/*',
26
+ included: false,
27
+ served: true,
28
+ watched: false,
29
+ nocache: true
30
+ },
31
+ {
32
+ pattern: 'test_base/css/*.css',
33
+ included: false,
34
+ served: true,
35
+ watched: false,
36
+ nocache: true
37
+ },
38
+ ],
39
+ customContextFile: 'test_base/html/custom_context.html',
40
+ customDebugFile: 'test_base/html/custom_debug.html',
41
+ proxies: {
42
+ '/release/': '/absolute' + path.resolve('./release') + '/',
43
+ '/src/': '/absolute' + path.resolve('./src') + '/',
44
+ '/css/': '/base/test_base/css/',
45
+ '/js/': '/base/test_base/js/',
46
+ '/resources/': '/base/test_base/resources/'
47
+ },
48
+ plugins: [
49
+ 'karma-firefox-launcher',
50
+ 'karma-chrome-launcher',
51
+ 'karma-ie-launcher',
52
+ '@chiragrupani/karma-chromium-edge-launcher',
53
+ 'karma-chai',
54
+ 'karma-mocha',
55
+ 'karma-mocha-reporter',
56
+ 'karma-webpack'
57
+ ],
58
+ customLaunchers: {
59
+ FirefoxCustom: {
60
+ base: 'Firefox',
61
+ prefs: {
62
+ 'dom.w3c_touch_events.enabled': 1,
63
+ 'dom.w3c_touch_events.legacy_apis.enabled': true
64
+ },
65
+ flags: ['-width', 400, '-height', 400]
66
+ },
67
+ FirefoxCustomHeadless: {
68
+ base: 'FirefoxHeadless',
69
+ prefs: {
70
+ 'dom.w3c_touch_events.enabled': 1,
71
+ 'dom.w3c_touch_events.legacy_apis.enabled': true
72
+ },
73
+ flags: ['-width', 400, '-height', 400]
74
+ },
75
+ ChromeCustom: {
76
+ base: 'Chrome',
77
+ flags: ['--disable-translate', '--disable-extensions']
78
+ },
79
+ ChromeCustomHeadless: {
80
+ base: 'ChromeHeadless',
81
+ flags: ['--disable-translate', '--disable-extensions', '--no-sandbox']
82
+ }
83
+ },
84
+ preprocessors: {
85
+ 'test_base/*_test.js': ['webpack']
86
+ },
87
+ // webpackの設定
88
+ webpack: {
89
+ mode: 'development',
90
+ target: ["web", "es5"],
91
+ resolve: {
92
+ mainFields: ['browser', 'main', 'module']
93
+ },
94
+ module: {
95
+ rules: [
96
+ {
97
+ test: /\.js$/,
98
+ exclude: /(node_modules|bower_components)/,
99
+ use: { loader: 'babel-loader' }
100
+ }
101
+ ]
102
+ }
103
+ },
104
+ reporters: ['mocha'],
105
+ // reporter options
106
+ mochaReporter: {
107
+ showDiff: true
108
+ },
109
+ port: 9876, // karma web server port
110
+ colors: true,
111
+ logLevel: config.LOG_INFO,
112
+ browsers: ['FirefoxCustom', 'FirefoxCustomHeadless', 'IE', 'Chrome', 'ChromeHeadless', 'Edge', 'EdgeHeadless'],
113
+ autoWatch: false,
114
+ // singleRun: false, // Karma captures browsers, runs the tests and exits
115
+ concurrency: Infinity
116
+ })
117
+ }
@@ -0,0 +1,86 @@
1
+ const path = require('path')
2
+
3
+ module.exports = function (config) {
4
+ config.set({
5
+ frameworks: ['mocha', 'webpack'],
6
+ files: [
7
+ 'test/*_test.js',
8
+ {
9
+ pattern: '../../release/*.js',
10
+ included: false,
11
+ served: true,
12
+ watched: false,
13
+ nocache: true
14
+ },
15
+ {
16
+ pattern: '../../src/*.css',
17
+ included: false,
18
+ served: true,
19
+ watched: false,
20
+ nocache: true
21
+ },
22
+ ],
23
+ customContextFile: 'test/html/custom_context.html',
24
+ customDebugFile: 'test/html/custom_debug.html',
25
+ proxies: {
26
+ '/release/': '/absolute' + path.resolve('./release') + '/',
27
+ '/src/': '/absolute' + path.resolve('./src') + '/'
28
+ },
29
+ plugins: [
30
+ 'karma-firefox-launcher',
31
+ 'karma-mocha',
32
+ 'karma-mocha-reporter',
33
+ 'karma-webpack'
34
+ ],
35
+ customLaunchers: {
36
+ FirefoxCustom: {
37
+ base: 'Firefox',
38
+ prefs: {
39
+ 'dom.w3c_touch_events.enabled': 1,
40
+ 'dom.w3c_touch_events.legacy_apis.enabled': true
41
+ },
42
+ flags: ['-width', 400, '-height', 400]
43
+ },
44
+ FirefoxCustomHeadless: {
45
+ base: 'FirefoxHeadless',
46
+ prefs: {
47
+ 'dom.w3c_touch_events.enabled': 1,
48
+ 'dom.w3c_touch_events.legacy_apis.enabled': true
49
+ },
50
+ flags: ['-width', 400, '-height', 400]
51
+ }
52
+ },
53
+ preprocessors: {
54
+ 'test/*_test.js': ['webpack']
55
+ },
56
+ // webpackの設定
57
+ webpack: {
58
+ mode: 'development',
59
+ target: ["web", "es5"],
60
+ resolve: {
61
+ mainFields: ['browser', 'main', 'module']
62
+ },
63
+ module: {
64
+ rules: [
65
+ {
66
+ test: /\.js$/,
67
+ exclude: /(node_modules|bower_components)/,
68
+ use: { loader: 'babel-loader' }
69
+ }
70
+ ]
71
+ }
72
+ },
73
+ reporters: ['mocha'],
74
+ // reporter options
75
+ mochaReporter: {
76
+ showDiff: true
77
+ },
78
+ port: 9876, // karma web server port
79
+ colors: true,
80
+ logLevel: config.LOG_INFO,
81
+ browsers: ['Firefox', 'FirefoxHeadless', 'FirefoxCustom', 'FirefoxCustomHeadless'],
82
+ autoWatch: false,
83
+ // singleRun: false, // Karma captures browsers, runs the tests and exits
84
+ concurrency: Infinity
85
+ })
86
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "sourceType": "module"
3
+ }
@@ -0,0 +1,69 @@
1
+ const assert = require('chai').assert
2
+
3
+ describe('bundled test', () => {
4
+ it('version', () => {
5
+ const els = document.getElementsByClassName('version-component')
6
+ if (els.length > 0) {
7
+ assert.ok(/日本語プログラミング言語「なでしこ3」/.test(els[0].innerHTML), 'notfound "日本語プログラミング言語「なでしこ3」" in version-component')
8
+ } else {
9
+ assert.fail('no element has version-component class')
10
+ }
11
+ })
12
+
13
+ describe('editor', () => {
14
+ let ta = null
15
+ let el = null
16
+ let run = null
17
+ let rslt = null
18
+ it('textarea default', () => {
19
+ const els = document.getElementsByClassName('editor-component')
20
+ if (els.length > 0) {
21
+ el = els[0]
22
+ ta = el.querySelector('.nako3_editor_code')
23
+ if (ta) {
24
+ assert.ok(/「こんにちは!」と表示。/.test(ta.innerText), 'HTML要素が文字列"「こんにちは!」と表示。"を含みません。')
25
+ } else {
26
+ assert.fail('no element has src class and not has src_read')
27
+ }
28
+ } else {
29
+ assert.fail('no element has editor-component class')
30
+ }
31
+ })
32
+ it('run', () => {
33
+ run = Array.from(el.querySelectorAll('button.default_button')).find(e => e.textContent === '実行')
34
+ if (run) {
35
+ const evt = new MouseEvent('click', {
36
+ view: window,
37
+ bubbles: true,
38
+ cancelable: true,
39
+ button: 0,
40
+ buttons: 1
41
+ })
42
+ run.dispatchEvent(evt)
43
+
44
+ return new Promise((resolve, reject) => {
45
+ setTimeout(() => {
46
+ try {
47
+ const rsltHead = Array.from(el.querySelectorAll('.edit_head')).find(e => e.textContent === '実行結果')
48
+ if (rsltHead) {
49
+ rslt = rsltHead.parentNode.querySelector('.info')
50
+ if (rslt) {
51
+ assert.ok(/こんにちは!.+9/m.test(rslt.innerHTML), '文字列「こんにちは!」と「9」が出力エリアに表示されていません。')
52
+ resolve()
53
+ } else {
54
+ assert.fail('.infoが存在しません。')
55
+ }
56
+ } else {
57
+ assert.fail('.edit_headを見つけられませんでした。')
58
+ }
59
+ } catch (err) {
60
+ reject(err)
61
+ }
62
+ }, 500)
63
+ })
64
+ } else {
65
+ assert.fail('no element 実行 button-component class')
66
+ }
67
+ })
68
+ })
69
+ })
@@ -0,0 +1,65 @@
1
+ <!DOCTYPE html>
2
+ <!--
3
+ This is the execution context.
4
+ Loaded within the iframe.
5
+ Reloaded before every execution run.
6
+ -->
7
+ <html>
8
+ <head>
9
+ <title></title>
10
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
11
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
12
+ <link rel="stylesheet" href="/src/wnako3_editor.css">
13
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.12/ace.js" integrity="sha512-GZ1RIgZaSc8rnco/8CXfRdCpDxRCphenIiZ2ztLy3XQfCbQUSCuk8IudvNHxkRA3oUg6q0qejgN/qqyG1duv5Q==" crossorigin="anonymous"></script>
14
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.12/ext-language_tools.min.js" integrity="sha512-8qx1DL/2Wsrrij2TWX5UzvEaYOFVndR7BogdpOyF4ocMfnfkw28qt8ULkXD9Tef0bLvh3TpnSAljDC7uyniEuQ==" crossorigin="anonymous"></script>
15
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.12/ext-options.min.js" integrity="sha512-oHR+WVzBiVZ6njlMVlDDLUIOLRDfUUfRQ55PfkZvgjwuvGqL4ohCTxaahJIxTmtya4jgyk0zmOxDMuLzbfqQDA==" crossorigin="anonymous"></script>
16
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.12/ext-code_lens.min.js" integrity="sha512-gsDyyKTnOmSWRDzUbpYcPjzVsEyFGSWeWefzVKvbMULPR2ElIlKKsOtU3ycfybN9kncZXKLFSsUiG3cgJUbc/g==" crossorigin="anonymous"></script>
17
+ </head>
18
+ <body>
19
+ <!-- editor -->
20
+ <div id="editor" class="edit_div">
21
+ <div class="editor-component">
22
+ <script type="application/json">
23
+ {
24
+ "title": "簡易エディタ",
25
+ "code": "「こんにちは!」と表示。\n(1 + 2)×3を表示。",
26
+ "autoLoad": true
27
+ }
28
+ </script>
29
+ </div>
30
+ </div>
31
+ <!-- version info -->
32
+ <div class="about-group">
33
+ <div class="version-component"></div>
34
+ </div>
35
+ <!-- なでしこ-->
36
+ <script src="/release/wnako3.js"></script>
37
+ <script src="/release/editor.js"></script>
38
+ <script src="/release/version.js"></script>
39
+ <script src="/release/plugin_markup.js"></script>
40
+ <script src="/release/plugin_turtle.js"></script>
41
+ <!-- The scripts need to be in the body DOM element, as some test running frameworks need the body
42
+ to have already been created so they can insert their magic into it. For example, if loaded
43
+ before body, Angular Scenario test framework fails to find the body and crashes and burns in
44
+ an epic manner. -->
45
+ <script src="context.js"></script>
46
+ <script type="text/javascript">
47
+ // Configure our Karma and set up bindings
48
+ %CLIENT_CONFIG%
49
+ window.__karma__.setupContext(window);
50
+
51
+ // All served files with the latest timestamps
52
+ %MAPPINGS%
53
+ </script>
54
+ <!-- Dynamically replaced with <script> tags -->
55
+ %SCRIPTS%
56
+ <!-- Since %SCRIPTS% might include modules, the `loaded()` call needs to be in a module too.
57
+ This ensures all the tests will have been declared before karma tries to run them. -->
58
+ <script type="module">
59
+ window.__karma__.loaded();
60
+ </script>
61
+ <script nomodule>
62
+ window.__karma__.loaded();
63
+ </script>
64
+ </body>
65
+ </html>
@@ -0,0 +1,66 @@
1
+ <!doctype html>
2
+ <!--
3
+ This file is almost the same as context.html - loads all source files,
4
+ but its purpose is to be loaded in the main frame (not within an iframe),
5
+ just for immediate execution, without reporting to Karma server.
6
+ -->
7
+ <html>
8
+ <head>
9
+ %X_UA_COMPATIBLE%
10
+ <title>Karma DEBUG RUNNER</title>
11
+ <link href="favicon.ico" rel="icon" type="image/x-icon" />
12
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
13
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
14
+ <link rel="stylesheet" href="/src/wnako3_editor.css">
15
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.12/ace.js" integrity="sha512-GZ1RIgZaSc8rnco/8CXfRdCpDxRCphenIiZ2ztLy3XQfCbQUSCuk8IudvNHxkRA3oUg6q0qejgN/qqyG1duv5Q==" crossorigin="anonymous"></script>
16
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.12/ext-language_tools.min.js" integrity="sha512-8qx1DL/2Wsrrij2TWX5UzvEaYOFVndR7BogdpOyF4ocMfnfkw28qt8ULkXD9Tef0bLvh3TpnSAljDC7uyniEuQ==" crossorigin="anonymous"></script>
17
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.12/ext-options.min.js" integrity="sha512-oHR+WVzBiVZ6njlMVlDDLUIOLRDfUUfRQ55PfkZvgjwuvGqL4ohCTxaahJIxTmtya4jgyk0zmOxDMuLzbfqQDA==" crossorigin="anonymous"></script>
18
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.12/ext-code_lens.min.js" integrity="sha512-gsDyyKTnOmSWRDzUbpYcPjzVsEyFGSWeWefzVKvbMULPR2ElIlKKsOtU3ycfybN9kncZXKLFSsUiG3cgJUbc/g==" crossorigin="anonymous"></script>
19
+ </head>
20
+ <body>
21
+ <!-- editor -->
22
+ <div id="editor" class="edit_div">
23
+ <div class="editor-component">
24
+ <script type="application/json">
25
+ {
26
+ "title": "簡易エディタ",
27
+ "code": "「こんにちは!」と表示。\n(1 + 2)×3を表示。",
28
+ "autoLoad": true
29
+ }
30
+ </script>
31
+ </div>
32
+ </div>
33
+ <!-- version info -->
34
+ <div class="about-group">
35
+ <div class="version-component"></div>
36
+ </div>
37
+ <!-- なでしこ-->
38
+ <script src="/release/wnako3.js"></script>
39
+ <script src="/release/editor.js"></script>
40
+ <script src="/release/version.js"></script>
41
+ <script src="/release/plugin_markup.js"></script>
42
+ <!-- The scripts need to be at the end of body, so that some test running frameworks
43
+ (Angular Scenario, for example) need the body to be loaded so that it can insert its magic
44
+ into it. If it is before body, then it fails to find the body and crashes and burns in an epic
45
+ manner. -->
46
+ <script src="context.js"></script>
47
+ <script src="debug.js"></script>
48
+ <script type="text/javascript">
49
+ // Configure our Karma
50
+ %CLIENT_CONFIG%
51
+
52
+ // All served files with the latest timestamps
53
+ %MAPPINGS%
54
+ </script>
55
+ <!-- Dynamically replaced with <script> tags -->
56
+ %SCRIPTS%
57
+ <!-- Since %SCRIPTS% might include modules, the `loaded()` call needs to be in a module too.
58
+ This ensures all the tests will have been declared before karma tries to run them. -->
59
+ <script type="module">
60
+ window.__karma__.loaded();
61
+ </script>
62
+ <script nomodule>
63
+ window.__karma__.loaded();
64
+ </script>
65
+ </body>
66
+ </html>
@@ -0,0 +1,52 @@
1
+ @echo off
2
+ setlocal
3
+ cd ../..
4
+
5
+ set BROWSER=FirefoxCustom
6
+ set HEADLESS=Headless
7
+
8
+ set SINGLEWATCH=--single-run
9
+
10
+ set TARGET_BASIC=
11
+ set TARGET_TURTLE=
12
+
13
+ FOR %%a IN (%*) DO (
14
+ if "%%~a"=="ff" (set BROWSER=FirefoxCustom)
15
+ if "%%~a"=="FF" (set BROWSER=FirefoxCustom)
16
+ if "%%~a"=="ie" (set BROWSER=IE)
17
+ if "%%~a"=="IE" (set BROWSER=IE)
18
+ if "%%~a"=="edge" (set BROWSER=Edge)
19
+ if "%%~a"=="Edge" (set BROWSER=Edge)
20
+ if "%%~a"=="EDGE" (set BROWSER=Edge)
21
+ if "%%~a"=="chrome" (set BROWSER=ChromeCustom)
22
+ if "%%~a"=="Chrome" (set BROWSER=ChromeCustom)
23
+ if "%%~a"=="CHROME" (set BROWSER=ChromeCustom)
24
+ if "%%~a"=="hide" (set HEADLESS=Headless)
25
+ if "%%~a"=="HIDE" (set HEADLESS=Headless)
26
+ if "%%~a"=="view" (set HEADLESS=)
27
+ if "%%~a"=="VIEW" (set HEADLESS=)
28
+ if "%%~a"=="watch" (set SINGLEWATCH=--auto-watch)
29
+ if "%%~a"=="WATCH" (set SINGLEWATCH=--auto-watch)
30
+ if "%%~a"=="basic" (set TARGET_BASIC=YES)
31
+ if "%%~a"=="BASIC" (set TARGET_BASIC=YES)
32
+ if "%%~a"=="turtle" (set TARGET_TURTLE=YES)
33
+ if "%%~a"=="TURTLE" (set TARGET_TURTLE=YES)
34
+ )
35
+
36
+ if "%BROWSER%"=="IE" (set HEADLESS=)
37
+
38
+ if "%TARGET_BASIC%%TARGET_TURTLE%"=="" (
39
+ set TARGET_BASIC=YES
40
+ set TARGET_TURTLE=
41
+ )
42
+
43
+
44
+ @echo on
45
+ if "%TARGET_BASIC%"=="YES" (
46
+ call node_modules\.bin\cross-env TZ=Asia/Tokyo NODE_ENV=development node_modules\.bin\karma start %SINGLEWATCH% --browsers %BROWSER%%HEADLESS% --reporters=mocha test/bundled/karma.config.base.js
47
+ )
48
+ @echo on
49
+ if "%TARGET_TURTLE%"=="YES" (
50
+ call node_modules\.bin\cross-env TZ=Asia/Tokyo NODE_ENV=development node_modules\.bin\karma start %SINGLEWATCH% --browsers %BROWSER%%HEADLESS% --reporters=mocha test_browsers/karma.config.turtle.js
51
+ )
52
+ endlocal
@@ -0,0 +1,3 @@
1
+ {
2
+ "sourceType": "script"
3
+ }
@@ -0,0 +1,25 @@
1
+ const TestEnv = require('./test_utils').TestEnv
2
+
3
+ describe('browsers test', function () {
4
+
5
+ const env = new TestEnv()
6
+ before( function () {
7
+ env.getEnv()
8
+ })
9
+
10
+ describe('check testtool', function () {
11
+
12
+ it('context check', function () {
13
+ env.checkEnv()
14
+ })
15
+ it('info check', function () {
16
+ env.cmpInfo('「こんにちは」を表示する。', "こんにちは")
17
+ })
18
+ it('report check', function () {
19
+ env.cmpReport('「こんにちは」を報告する。', ["こんにちは"])
20
+ })
21
+ it('error check', function () {
22
+ env.cmpError('「こんにちは」を食べる。', {name: 'Error', message: /単語『食』が解決していません。/} )
23
+ })
24
+ })
25
+ })