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,56 @@
1
+ const TestEnv = require('./test_utils').TestEnv
2
+
3
+ describe('basic ajax', () => {
4
+ const env = new TestEnv()
5
+ before( function () {
6
+ env.getEnv()
7
+ })
8
+
9
+ it('POSTデータ生成', () => {
10
+ const code = `
11
+ パラメータは空オブジェクト。
12
+ パラメータ["KEY"]は、「VALUE」。
13
+ パラメータ["_X"]は、「XE^ZA」。
14
+ パラメータ["SPACE"]は、「 」。
15
+ パラメータをPOSTデータ生成して報告する。
16
+ `
17
+ env.cmpReport(code, ["KEY=VALUE&_X=XE%5EZA&SPACE=%20"])
18
+ })
19
+
20
+ it('AJAXオプション設定', () => {
21
+ const code = `
22
+ パラメータは空オブジェクト。
23
+ パラメータ["KEY"]は、「VALUE」。
24
+ パラメータにAJAXオプション設定する。
25
+ AJAXオプションを報告する。
26
+ `
27
+ env.cmpReport(code, [{"KEY":"VALUE"}])
28
+ })
29
+
30
+ it('AJAX送信時', (done) => {
31
+ const code = '「/resources/ok.txt」へAJAX送信時には;対象を報告する;ここまで'
32
+ env.waitCmpReport(done ,code, ["OK"])
33
+ })
34
+
35
+ it('POST送信時', (done) => {
36
+ const code = `
37
+ パラメータは空オブジェクト。
38
+ パラメータ["param1"]は、「data1^」。
39
+ パラメータ["param2"]は、「data2^^」。
40
+ パラメータを「/resources/ok.txt」へPOST送信時には
41
+ 対象を報告する。
42
+ ここまで
43
+ `
44
+ env.waitCmpReport(done ,code, ["OK"])
45
+ }).timeout(10000)
46
+
47
+ it('AJAX送信', (done) => {
48
+ const code = `
49
+ 逐次実行
50
+ 次に、「/resources/ok.txt」へAJAX送信する。
51
+ 次に、対象を報告する。
52
+ ここまで
53
+ `
54
+ env.waitCmpReport(done ,code, ["OK"])
55
+ })
56
+ })
@@ -0,0 +1,18 @@
1
+ const TestEnv = require('./test_utils').TestEnv
2
+
3
+ describe('basic async', () => {
4
+ const env = new TestEnv()
5
+ before( function () {
6
+ env.getEnv()
7
+ })
8
+
9
+ it('同期タイマー', (done) => {
10
+ const code = '' +
11
+ '逐次実行\n' +
12
+ '先に、0.01秒待機\n' +
13
+ '次に、30を報告\n' +
14
+ 'ここまで。\n'
15
+ env.waitCmpReport(done ,code, [30])
16
+ })
17
+
18
+ })
@@ -0,0 +1,153 @@
1
+ const TestEnv = require('./test_utils').TestEnv
2
+
3
+ describe('basic', () => {
4
+ const env = new TestEnv()
5
+ before( function () {
6
+ env.getEnv()
7
+ })
8
+
9
+ const cmp = (code, res) => {
10
+ env.cmpInfo(code, res)
11
+ }
12
+ // --- test ---
13
+ it('print simple', () => {
14
+ cmp('3を表示', '3')
15
+ })
16
+ it('print', () => {
17
+ cmp('3を表示', '3')
18
+ cmp('100を表示', '100')
19
+ cmp('0xFFを表示', '255')
20
+ })
21
+ it('string', () => {
22
+ cmp('「abc」を表示', 'abc')
23
+ cmp('"abc"を表示', 'abc')
24
+ cmp('“あいう”を表示', 'あいう')
25
+ })
26
+ it('rawstring', () => {
27
+ cmp('『abc』を表示', 'abc')
28
+ cmp('\'abc\'を表示', 'abc')
29
+ cmp('『abc{30}abc』を表示', 'abc{30}abc')
30
+ })
31
+ it('exstring', () => {
32
+ cmp('a=30;「abc{a}abc」を表示', 'abc30abc')
33
+ cmp('a=30;「abc{a}abc」を表示', 'abc30abc')
34
+ })
35
+ it('raw string - 🌿 .. 🌿', () => {
36
+ cmp('a=🌿abc🌿;aを表示', 'abc')
37
+ })
38
+ it('EX string - 🌴 .. 🌴', () => {
39
+ cmp('v=30;a=🌴abc{v}abc🌴;aを表示', 'abc30abc')
40
+ })
41
+ it('string - LF', () => {
42
+ cmp('a=30;「abc\nabc」を表示', 'abc\nabc')
43
+ })
44
+ it('space 「・」', () => {
45
+ cmp('・a=30;・b=50「{a}-{b}」を表示', '30-50')
46
+ })
47
+ it('string - 🌴 ... 🌴', () => {
48
+ cmp('🌴aaa🌴を表示', 'aaa')
49
+ cmp('a=30;🌴aaa{a}bbb🌴を表示', 'aaa30bbb')
50
+ cmp('a=30;🌿aaa{a}bbb🌿を表示', 'aaa{a}bbb')
51
+ })
52
+ it('システム定数', () => {
53
+ cmp('ナデシコエンジンを表示', 'nadesi.com/v3')
54
+ })
55
+ it('助詞の後に句読点', () => {
56
+ cmp('「こんにちは」と、表示。', 'こんにちは')
57
+ })
58
+ it('代入文', () => {
59
+ cmp('3000を値段に代入。値段を表示', '3000')
60
+ cmp('値段に3000を代入。値段を表示', '3000')
61
+ cmp('々=3000。々を表示', '3000')
62
+ cmp('々に3000を代入。々を表示', '3000')
63
+ })
64
+ it('連文後の代入文', () => {
65
+ cmp('「aabbcc」の「aa」を「」に置換してFに代入。Fを表示', 'bbcc')
66
+ cmp('「aabbcc」の「aa」を「」に置換して「bb」を「」に置換してFに代入。Fを表示', 'cc')
67
+ })
68
+ it('〜を〜に定める', () => {
69
+ cmp('Aを0.8に定めてAを表示', '0.8')
70
+ })
71
+ it('文字列 - &と改行', () => {
72
+ cmp('「aaa」& _\n「bbb」を表示。', 'aaabbb')
73
+ cmp('A= 1 + 1 + 1 + 1 + 1 + _\n1 + 1\nAを表示', '7')
74
+ cmp('A= 1 + 1 + 1 + 1 + 1 + _\r\n1 + 1 + 1\r\nAを表示', '8')
75
+ cmp('A= 1 + 1 + 1 + 1 + 1 + _ \r\n1 + 3 \r\nAを表示', '9')
76
+ cmp('A = 1 + _\n' +
77
+ ' 5 + _\n' +
78
+ ' 10\n' +
79
+ 'Aを表示。', '16')
80
+ })
81
+ it('名前に数字を持つ変数を使う', () => {
82
+ cmp('A1=30;B1=20;「{A1}{B1}」を表示。', '3020')
83
+ })
84
+ it('名前に絵文字を持つ変数を使う', () => {
85
+ cmp('\u1F60=30;\u1F60を表示。', '30')
86
+ cmp('😄=30;😄を表示。', '30')
87
+ })
88
+ it('ラインコメントが正しく処理されない問題 (#112)', () => {
89
+ cmp('A=50 # hogehoge\nAを表示', '50')
90
+ cmp('A=50 # hogehoge\nAを表示', '50')
91
+ cmp('A=50 ※ hogehoge\nAを表示', '50')
92
+ cmp('A=50 // hogehoge\nAを表示', '50')
93
+ cmp('A=50 // hogehoge\nAを表示', '50')
94
+ cmp('A=50\nもしA=50ならば # hogehoge\nAを表示\nここまで\n', '50')
95
+ cmp('A=50\nもしA=50ならば # hogehoge\nAを表示\nここまで\n', '50')
96
+ cmp('A=50\nもしA=50ならば ※ hogehoge\nAを表示\nここまで\n', '50')
97
+ cmp('A=50\nもしA=50ならば // hogehoge\nAを表示\nここまで\n', '50')
98
+ cmp('A=50\nもしA=50ならば // hogehoge\nAを表示\nここまで\n', '50')
99
+ })
100
+ it('ラインコメントに文字列記号があり閉じていないとエラーになる(#725)', () => {
101
+ cmp('A=50 # \"hogehoge\nAを表示', '50')
102
+ })
103
+ it('範囲コメントに文字列記号があり閉じていないとエラーになる(#731)', () => {
104
+ cmp('A=50 /* " */Aを表示', '50')
105
+ cmp('A=50 /* \' */Aを表示', '50')
106
+ })
107
+ it('論文などで使われる句読点「,」を「、」(#735)', () => {
108
+ cmp('A1=30;B1=20;(A1+B1)を,表示', '50')
109
+ cmp('A=3.14;Aを,表示', '3.14')
110
+ })
111
+ it('条件分岐のインデント構文', () => {
112
+ cmp(
113
+ '!インデント構文\n' +
114
+ '3で条件分岐\n' +
115
+ ' 2ならば\n' +
116
+ ' 1を表示\n' +
117
+ ' 3ならば\n' +
118
+ ' 2を表示\n' +
119
+ ' 違えば\n' +
120
+ ' 3を表示\n',
121
+ '2'
122
+ )
123
+ })
124
+ it('空白で区切って文をつなげた場合', () => {
125
+ cmp('1と2を足す 1と2を足す', '')
126
+ })
127
+ it('制御構文で一語関数を使う', () => {
128
+ cmp('●一とは\n1を戻す\nここまで\nもし一ならば\n1を表示\nここまで', '1') // if
129
+ cmp('●一とは\n1を戻す\nここまで\n一回\n1を表示\nここまで', '1') // times
130
+ cmp('●一とは\n1を戻す\nここまで\n一の間\n1を表示\n抜ける\nここまで', '1') // while
131
+ cmp('●一とは\n[1]を戻す\nここまで\n一を反復\n1を表示\nここまで', '1') // foreach
132
+ cmp('●一とは\n1を戻す\nここまで\n一で条件分岐\n1ならば\n1を表示\nここまで\nここまで', '1') // switch
133
+ })
134
+ it('そう', () => {
135
+ // 「そう」は「それ」のエイリアス
136
+ cmp('それ=1;そうを表示', '1')
137
+ cmp('1に3を足す;そうを表示', '4')
138
+ })
139
+ it('「〜時間」の「間」を制御構文として認識させない #831', () => {
140
+ cmp('時間=1\n(時間)を表示', '1')
141
+ })
142
+ it('「もしFが存在するならば」がFと「存在する」の比較になる問題の修正 #830', () => {
143
+ cmp('●(Aが)hogeとは\n' +
144
+ ' 1を戻す\n' +
145
+ 'ここまで\n' +
146
+ 'もし、Fがhogeならば\n' +
147
+ ' 1を表示\n' +
148
+ 'ここまで',
149
+ // ---
150
+ '1')
151
+ })
152
+
153
+ })
@@ -0,0 +1,132 @@
1
+ const TestEnv = require('./test_utils').TestEnv
2
+
3
+ describe('calc_test.js', () => {
4
+ const env = new TestEnv()
5
+ before( function () {
6
+ env.getEnv()
7
+ })
8
+
9
+ const cmp = (code, res) => {
10
+ env.cmpInfo(code, res)
11
+ }
12
+ it('basic', () => {
13
+ cmp('3を表示', '3')
14
+ cmp('3.14を表示', '3.14')
15
+ cmp('0.5e+3を表示', '500')
16
+ })
17
+ it('足し算', () => {
18
+ cmp('3+5を表示', '8')
19
+ })
20
+ it('引き算', () => {
21
+ cmp('10-5を表示。', '5')
22
+ cmp('10-5を表示。', '5')
23
+ })
24
+ it('掛け算', () => {
25
+ cmp('1+2*3を表示', '7')
26
+ })
27
+ it('連続演算:して', () => {
28
+ cmp('3に5を足して表示', '8')
29
+ })
30
+ it('連続演算:て-3に5を掛けて表示', () => {
31
+ cmp('3に5を掛けて表示', '15')
32
+ })
33
+ it('配列', () => {
34
+ cmp('a=[];a[1]=30;a[1]を表示', '30')
35
+ cmp('a=[];a【1】=30;a[1]を表示', '30')
36
+ })
37
+ it('ネスト配列', () => {
38
+ cmp('a=[[1,2,3], [4,5,6]];a[1][1]を表示', '5')
39
+ })
40
+ it('ネスト配列で、マイナスを含むときのバグ修正 (#276)', () => {
41
+ cmp('a=[[-1, -1], [1, -1]];a[0][0]を表示', '-1')
42
+ })
43
+ it('オブジェクト', () => {
44
+ cmp('a={};a[\'a\']=30;a[\'a\']を表示', '30')
45
+ })
46
+ it('階乗', () => {
47
+ cmp('2^3を表示', '8')
48
+ })
49
+ it('否定', () => {
50
+ cmp('(!1)を表示', '0')
51
+ cmp('(!0)を表示', '1')
52
+ cmp('(!オン)を表示', '0')
53
+ cmp('(!オフ)を表示', '1')
54
+ })
55
+ it('配列簡易記号', () => {
56
+ cmp('A=[];A@0=5;A@0を表示', '5')
57
+ cmp('A=[];A@0=5;A@1=6;AをJSONエンコードして表示', '[5,6]')
58
+ })
59
+ it('JSON配列-改行あり', () => {
60
+ cmp('A=[\n0,\n1,\n2,\n3];A@2を表示', '2')
61
+ })
62
+ it('JSON配列-カンマ省略', () => {
63
+ cmp('A=[1 2 3 4 5];AをJSONエンコードして表示', '[1,2,3,4,5]')
64
+ })
65
+ it('JSON配列-ネスト', () => {
66
+ cmp('A=[[1,2,3],[4,5,6]];AをJSONエンコードして表示', '[[1,2,3],[4,5,6]]')
67
+ })
68
+ it('JSONオブジェクト-改行あり', () => {
69
+ cmp('A={\n"殿":"男","姫":"女"\n};A@"殿"を表示', '男')
70
+ })
71
+ it('JSONオブジェクト-値を省略した場合', () => {
72
+ cmp('N={"hoge"};N["hoge"]を表示。', 'hoge')
73
+ cmp('N={"hoge","fuga","bar"};N["bar"]を表示。', 'bar')
74
+ cmp('N={32,45,66};N[45]を表示。', '45')
75
+ })
76
+ it('JSONオブジェクト-キーを文字列で囲わなかった場合', () => {
77
+ cmp('N={hoge:30};N["hoge"]を表示。', '30')
78
+ })
79
+ it('文字列→数値への暗黙的変換', () => {
80
+ cmp('A="5";B="50";A+Bを表示', '55')
81
+ cmp('"100"/"2"を表示', '50')
82
+ cmp('"2"*"3"を表示', '6')
83
+ cmp('"100"%"10"を表示', '0')
84
+ })
85
+ it('空配列テスト', () => {
86
+ cmp('A=空配列;A@0=30;A@1=50;Aを「:」で配列結合して表示', '30:50')
87
+ cmp('A=空配列;B=空配列;A@0=30;A@1=50;B@0=1;Bを「:」で配列結合して表示', '1')
88
+ })
89
+ it('単項演算子 minus number', () => {
90
+ cmp('-1*5を表示', '-5')
91
+ cmp('5*-1を表示', '-5')
92
+ })
93
+ it('単項演算子 minus word', () => {
94
+ cmp('A=1;5*-Aを表示', '-5')
95
+ })
96
+ it('論理演算', () => {
97
+ cmp('BMI=25;A=((25 ≦ BMI) かつ (BMI < 30));Aを表示', 'true')
98
+ cmp('BMI=25;A=((18.5 > BMI) または (BMI > 30));Aを表示', 'false')
99
+ })
100
+ it('カッコ内の関数呼び出し', () => {
101
+ cmp('N=("ABC"の文字数);Nを表示。', '3')
102
+ })
103
+ it('文字列の埋め込み変数加算', () => {
104
+ cmp('N1=30;「--{N1+1}--」を表示', '--31--')
105
+ })
106
+ it('文字列の埋め込み変数減算', () => {
107
+ cmp('N1=30;「--{N1-1}--」を表示', '--29--')
108
+ })
109
+ it('文字列の埋め込み変数乗算', () => {
110
+ cmp('N1=30;「--{N1*2}--」を表示', '--60--')
111
+ })
112
+ it('文字列の埋め込み変数除算', () => {
113
+ cmp('N1=30;「--{N1/2}--」を表示', '--15--')
114
+ })
115
+ it('文字列の埋め込み変数剰余', () => {
116
+ cmp('N1=30;「--{N1%2}--」を表示', '--0--')
117
+ })
118
+ it('文字列の埋め込み変数冪乗', () => {
119
+ cmp('N1=2;「--{N1^3}--」を表示', '--8--')
120
+ })
121
+ it('比較演算子', () => {
122
+ cmp('A=1>5;Aを表示', 'false')
123
+ })
124
+ it('ビット演算', () => {
125
+ cmp('A=0xF0>>4;Aを表示', '15')
126
+ cmp('A=0xF<<4;Aを表示', '240')
127
+ })
128
+ it('連文で計算 (#729)', () => {
129
+ cmp('1に2を足して3を足して4を引いて5を掛けて2で割って表示', '5')
130
+ cmp('2に3を掛けて4を足して5で割って表示', '2')
131
+ })
132
+ })
@@ -0,0 +1,114 @@
1
+ /* reset style */
2
+ h1, h3, .sbox h4, .edit_head, .buttons, #info {
3
+ margin: 0;
4
+ }
5
+
6
+ h1, h3, #info {
7
+ padding: 0.5em;
8
+ }
9
+
10
+ /* title */
11
+ h1#title, h1 {
12
+ background-color: #fff0f0;
13
+ margin: 0;
14
+ padding: 4px;
15
+ color: black;
16
+ font-size: 1.3em;
17
+ }
18
+
19
+ /* menubar */
20
+ div.menubar {
21
+ background-color: #f0e0e0;
22
+ font-size: 0.8em;
23
+ color: black;
24
+ margin: 0; padding: 4px;
25
+ overflow: hidden;
26
+ }
27
+ h3, .info, .err, #src_box, .src {
28
+ font-size: 1em;
29
+ }
30
+
31
+ h3 {
32
+ background-color: #e0e0e0;
33
+ border-bottom: 1px solid gray;
34
+ }
35
+
36
+
37
+ .sbox h4 {
38
+ font-size: 0.9em;
39
+ padding: 4px;
40
+ }
41
+
42
+ .default_button {
43
+ min-width: 10em;
44
+ }
45
+ .mini_button {
46
+ width: 1em;
47
+ }
48
+
49
+ button {
50
+ padding: 0.4em;
51
+ cursor: pointer;
52
+ }
53
+
54
+ .turtle_canvas {
55
+ border: 1px solid silver;
56
+ }
57
+
58
+ .turtle_box, .buttons {
59
+ text-align: center;
60
+ }
61
+
62
+ .edit_head, .buttons {
63
+ padding: 0.3em;
64
+ }
65
+
66
+ .edit_head {
67
+ font-size: 0.8em;
68
+ color: gray;
69
+ }
70
+
71
+ .edit_div {
72
+ margin: 0.5em;
73
+ padding: 0;
74
+ }
75
+
76
+ .info, .err, #src_box, .src {
77
+ line-height: 1.5em;
78
+ }
79
+
80
+ .info, .err {
81
+ border: 1px solid gray;
82
+ padding: 8px;
83
+ }
84
+
85
+ .info {
86
+ background-color: #f0fff0;
87
+ margin-top: 0;
88
+ }
89
+
90
+ .err {
91
+ background-color: #fff0f0;
92
+ }
93
+
94
+ #src_box, .src, #info {
95
+ width: 99%;
96
+ }
97
+
98
+ #src_box {
99
+ background-color: #fffff0;
100
+ }
101
+
102
+ .src {
103
+ background-color: #fafafa;
104
+ }
105
+
106
+ .src_read {
107
+ background-color: #f0f0f0;
108
+ }
109
+
110
+ .sbox {
111
+ border-bottom: 1px solid silver;
112
+ margin: 8px;
113
+ padding: 12px;
114
+ }
@@ -0,0 +1,69 @@
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 http-equiv="X-UA-Compatible" content="IE=edge" >
12
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
13
+ <link rel="stylesheet" href="/css/browsers_box.css">
14
+ </head>
15
+ <body>
16
+ <h1>なでしこブラウザテスト</h1>
17
+ <!-- editor -->
18
+ <div id="editor" class="edit_div">
19
+ <h2 class="edit_head">簡易エディタ:</h2>
20
+ <textarea id="src_box" rows="4"></textarea>
21
+ <div class="buttons">
22
+ <button id="run_button" class="default_button">実行</button>
23
+ <button id="reset_button" class="default_button">クリア</button>
24
+ </div>
25
+ <div class="result_box">
26
+ <h3 class="edit_head">結果:</h3>
27
+ <textarea id="info" class="info" style="textAlign: left"></textarea>
28
+ <div id="json" class="info" style="textAlign: left"></div>
29
+ <div id="err" class="err"><span id="errName"></span><br><span id="errMessage"></span></div>
30
+ <!-- <canvas id="turtle_cv" class="turtle_canvas" width="280" height="380"></canvas>
31
+ <div id="turtle3d_div" class="turtle_div" width="280" height="380" style="width:280;height:380"></div> -->
32
+ </div>
33
+ </div>
34
+ <!-- なでしこ-->
35
+ <script src="/release/wnako3.js"></script>
36
+ <script src="/js/browsers_box.js"></script>
37
+ <script src="/release/plugin_kansuji.js"></script>
38
+ <script src="/release/plugin_markup.js"></script>
39
+ <script src="/release/plugin_datetime.js"></script>
40
+ <script src="/release/plugin_csv.js"></script>
41
+ <script src="/release/plugin_caniuse.js"></script>
42
+ <script src="/release/plugin_webworker.js"></script>
43
+ <!-- <script src="/release/plugin_turtle.js"></script> -->
44
+ <!-- <script src="/release/plugin_weykturtle3d.js"></script> -->
45
+ <!-- The scripts need to be in the body DOM element, as some test running frameworks need the body
46
+ to have already been created so they can insert their magic into it. For example, if loaded
47
+ before body, Angular Scenario test framework fails to find the body and crashes and burns in
48
+ an epic manner. -->
49
+ <script src="context.js"></script>
50
+ <script type="text/javascript">
51
+ // Configure our Karma and set up bindings
52
+ %CLIENT_CONFIG%
53
+ window.__karma__.setupContext(window);
54
+
55
+ // All served files with the latest timestamps
56
+ %MAPPINGS%
57
+ </script>
58
+ <!-- Dynamically replaced with <script> tags -->
59
+ %SCRIPTS%
60
+ <!-- Since %SCRIPTS% might include modules, the `loaded()` call needs to be in a module too.
61
+ This ensures all the tests will have been declared before karma tries to run them. -->
62
+ <script type="module">
63
+ window.__karma__.loaded();
64
+ </script>
65
+ <script nomodule>
66
+ window.__karma__.loaded();
67
+ </script>
68
+ </body>
69
+ </html>
@@ -0,0 +1,71 @@
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
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" >
12
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
13
+ <link href="favicon.ico" rel="icon" type="image/x-icon" />
14
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
15
+ <link rel="stylesheet" href="/css/browsers_box.css">
16
+ </head>
17
+ <body>
18
+ <h1>なでしこブラウザテスト</h1>
19
+ <!-- editor -->
20
+ <div id="editor" class="edit_div">
21
+ <h2 class="edit_head">簡易エディタ:</h2>
22
+ <textarea id="src_box" rows="4"></textarea>
23
+ <div class="buttons">
24
+ <button id="run_button" class="default_button">実行</button>
25
+ <button id="reset_button" class="default_button">クリア</button>
26
+ </div>
27
+ <div class="result_box">
28
+ <h3 class="edit_head">結果:</h3>
29
+ <textarea id="info" class="info" style="textAlign: left"></textarea>
30
+ <div id="json" class="info" style="textAlign: left"></div>
31
+ <div id="err" class="err"><span id="errName"></span><br><span id="errMessage"></span></div>
32
+ <!-- <canvas id="turtle_cv" class="turtle_canvas" width="280" height="380"></canvas>
33
+ <div id="turtle3d_div" class="turtle_div" width="280" height="380" style="width:280;height:380"></div> -->
34
+ </div>
35
+ </div>
36
+ <!-- なでしこ-->
37
+ <script src="/release/wnako3.js"></script>
38
+ <script src="/js/browsers_box.js"></script>
39
+ <script src="/release/plugin_kansuji.js"></script>
40
+ <script src="/release/plugin_markup.js"></script>
41
+ <script src="/release/plugin_datetime.js"></script>
42
+ <script src="/release/plugin_csv.js"></script>
43
+ <script src="/release/plugin_caniuse.js"></script>
44
+ <script src="/release/plugin_webworker.js"></script>
45
+ <!-- <script src="/release/plugin_turtle.js"></script> -->
46
+ <!-- <script src="/release/plugin_weykturtle3d.js"></script> -->
47
+ <!-- The scripts need to be at the end of body, so that some test running frameworks
48
+ (Angular Scenario, for example) need the body to be loaded so that it can insert its magic
49
+ into it. If it is before body, then it fails to find the body and crashes and burns in an epic
50
+ manner. -->
51
+ <script src="context.js"></script>
52
+ <script src="debug.js"></script>
53
+ <script type="text/javascript">
54
+ // Configure our Karma
55
+ %CLIENT_CONFIG%
56
+
57
+ // All served files with the latest timestamps
58
+ %MAPPINGS%
59
+ </script>
60
+ <!-- Dynamically replaced with <script> tags -->
61
+ %SCRIPTS%
62
+ <!-- Since %SCRIPTS% might include modules, the `loaded()` call needs to be in a module too.
63
+ This ensures all the tests will have been declared before karma tries to run them. -->
64
+ <script type="module">
65
+ window.__karma__.loaded();
66
+ </script>
67
+ <script nomodule>
68
+ window.__karma__.loaded();
69
+ </script>
70
+ </body>
71
+ </html>