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.
- package/LICENSE +21 -0
- package/README.md +107 -0
- package/bin/cnako3 +10 -0
- package/bin/cnako3.bat +11 -0
- package/bin/nako3server.bat +6 -0
- package/demo/ace_editor.html +90 -0
- package/demo/ace_editor_tabs.html +162 -0
- package/demo/basic.html +71 -0
- package/demo/browsers.html +128 -0
- package/demo/css/basic.css +3 -0
- package/demo/css/common.css +157 -0
- package/demo/css/editor.css +8 -0
- package/demo/css/flow.css +3 -0
- package/demo/css/index.css +3 -0
- package/demo/extlib/ace@1.4.12/ace.js +17 -0
- package/demo/extlib/ace@1.4.12/ext-code_lens.min.js +1 -0
- package/demo/extlib/ace@1.4.12/ext-language_tools.min.js +1 -0
- package/demo/extlib/ace@1.4.12/ext-options.min.js +1 -0
- package/demo/extlib/ace@1.4.12/ext-settings_menu.js +8 -0
- package/demo/extlib/ace@1.4.12/keybinding-vscode.js +8 -0
- package/demo/extlib/ace@1.4.12/theme-monokai.js +8 -0
- package/demo/extlib/ace@1.4.12/theme-xcode.js +8 -0
- package/demo/extlib/chart.js@3.2.1/chart.min.js +13 -0
- package/demo/extlib/pure-min.css +11 -0
- package/demo/flow.html +97 -0
- package/demo/graph.html +53 -0
- package/demo/image/nako.png +0 -0
- package/demo/image/nakopad-icon256.png +0 -0
- package/demo/image/turtle.fla +0 -0
- package/demo/image/turtle.png +0 -0
- package/demo/index.html +134 -0
- package/demo/js/common.js +17 -0
- package/demo/js/turtle3d_test.js +44 -0
- package/demo/js/turtle_test.js +44 -0
- package/demo/runscript.html +47 -0
- package/demo/runscript2.html +33 -0
- package/demo/turtle.html +58 -0
- package/demo/turtle2.html +141 -0
- package/demo/turtle3.html +278 -0
- package/demo/turtle3d.html +58 -0
- package/demo/turtle3d2.html +107 -0
- package/demo/version.html +24 -0
- package/doc/SETUP.md +172 -0
- package/doc/about.md +34 -0
- package/doc/browsers.md +60 -0
- package/doc/docgen.md +21 -0
- package/doc/editor.md +44 -0
- package/doc/files.md +37 -0
- package/doc/plugins.md +195 -0
- package/doc/release.md +78 -0
- package/doc/win32.md +57 -0
- package/package.json +196 -0
- package/release/_hash.txt +65 -0
- package/release/_script-tags.txt +13 -0
- package/release/command.json +1 -0
- package/release/command.json.js +1 -0
- package/release/command_cnako3.json +1 -0
- package/release/command_list.json +1 -0
- package/release/editor.js +2 -0
- package/release/editor.js.LICENSE.txt +32 -0
- package/release/josi.json +48 -0
- package/release/nako_gen_async.js +1 -0
- package/release/nako_gen_async.js.LICENSE.txt +595 -0
- package/release/plugin_caniuse.js +1 -0
- package/release/plugin_caniuse.js.LICENSE.txt +411 -0
- package/release/plugin_csv.js +1 -0
- package/release/plugin_csv.js.LICENSE.txt +367 -0
- package/release/plugin_datetime.js +1 -0
- package/release/plugin_datetime.js.LICENSE.txt +471 -0
- package/release/plugin_kansuji.js +1 -0
- package/release/plugin_kansuji.js.LICENSE.txt +491 -0
- package/release/plugin_markup.js +1 -0
- package/release/plugin_markup.js.LICENSE.txt +363 -0
- package/release/plugin_turtle.js +1 -0
- package/release/plugin_turtle.js.LICENSE.txt +435 -0
- package/release/plugin_webworker.js +1 -0
- package/release/plugin_webworker.js.LICENSE.txt +491 -0
- package/release/version.js +2 -0
- package/release/version.js.LICENSE.txt +32 -0
- package/release/wnako3.js +2 -0
- package/release/wnako3.js.LICENSE.txt +1 -0
- package/release/wnako3webworker.js +1 -0
- package/release/wnako3webworker.js.LICENSE.txt +847 -0
- package/release/yoyakugo.json +30 -0
- package/src/browsers.md +60 -0
- package/src/cnako3.js +466 -0
- package/src/commander_ja.js +154 -0
- package/src/enako3.js +69 -0
- package/src/era.json +22 -0
- package/src/index.js +5 -0
- package/src/nako3.js +836 -0
- package/src/nako3_assert.js +37 -0
- package/src/nako3editorfix.sfd +106 -0
- package/src/nako3editorfix.woff +0 -0
- package/src/nako3server.js +51 -0
- package/src/nako_colors.js +86 -0
- package/src/nako_errors.js +176 -0
- package/src/nako_gen.js +1459 -0
- package/src/nako_gen_async.js +1622 -0
- package/src/nako_global.js +113 -0
- package/src/nako_indent.js +480 -0
- package/src/nako_josi_list.js +46 -0
- package/src/nako_lex_rules.js +259 -0
- package/src/nako_lexer.js +576 -0
- package/src/nako_logger.js +138 -0
- package/src/nako_parser3.js +1768 -0
- package/src/nako_parser_base.js +265 -0
- package/src/nako_parser_const.js +37 -0
- package/src/nako_prepare.js +293 -0
- package/src/nako_reserved_words.js +35 -0
- package/src/nako_source_mapping.js +251 -0
- package/src/nako_test.js +37 -0
- package/src/nako_version.js +8 -0
- package/src/plugin_browser.js +191 -0
- package/src/plugin_browser_ajax.js +352 -0
- package/src/plugin_browser_audio.js +109 -0
- package/src/plugin_browser_canvas.js +462 -0
- package/src/plugin_browser_chart.js +296 -0
- package/src/plugin_browser_color.js +49 -0
- package/src/plugin_browser_crypto.js +26 -0
- package/src/plugin_browser_dialog.js +53 -0
- package/src/plugin_browser_dom_basic.js +322 -0
- package/src/plugin_browser_dom_event.js +193 -0
- package/src/plugin_browser_dom_parts.js +163 -0
- package/src/plugin_browser_geolocation.js +51 -0
- package/src/plugin_browser_hotkey.js +25 -0
- package/src/plugin_browser_html.js +59 -0
- package/src/plugin_browser_in_worker.js +44 -0
- package/src/plugin_browser_location.js +21 -0
- package/src/plugin_browser_speech.js +111 -0
- package/src/plugin_browser_storage.js +121 -0
- package/src/plugin_browser_system.js +12 -0
- package/src/plugin_browser_websocket.js +73 -0
- package/src/plugin_caniuse.js +24 -0
- package/src/plugin_csv.js +57 -0
- package/src/plugin_datetime.js +414 -0
- package/src/plugin_express.js +212 -0
- package/src/plugin_kansuji.js +224 -0
- package/src/plugin_keigo.js +55 -0
- package/src/plugin_markup.js +32 -0
- package/src/plugin_math.js +319 -0
- package/src/plugin_node.js +1018 -0
- package/src/plugin_promise.js +94 -0
- package/src/plugin_system.js +2109 -0
- package/src/plugin_test.js +38 -0
- package/src/plugin_turtle.js +646 -0
- package/src/plugin_webworker.js +334 -0
- package/src/plugin_weykturtle3d.js +1216 -0
- package/src/plugin_worker.js +92 -0
- package/src/repl.nako3 +63 -0
- package/src/turtle-elephant.png +0 -0
- package/src/turtle-panda.png +0 -0
- package/src/turtle64.png +0 -0
- package/src/wnako3.js +162 -0
- package/src/wnako3_editor.css +215 -0
- package/src/wnako3_editor.js +1645 -0
- package/src/wnako3_editor_marker_red.png +0 -0
- package/src/wnako3_editor_marker_red.xcf +0 -0
- package/src/wnako3_editor_marker_yellow.png +0 -0
- package/src/wnako3_editor_marker_yellow.xcf +0 -0
- package/src/wnako3webworker.js +70 -0
- package/test/ace_editor/karma.config.js +94 -0
- package/test/ace_editor/test/.babelrc.json +3 -0
- package/test/ace_editor/test/ace_editor_test.js +178 -0
- package/test/ace_editor/test/html/custom_context.html +140 -0
- package/test/async/async_basic_test.js +124 -0
- package/test/browser/karma.config.js +212 -0
- package/test/browser/test/.babelrc.json +3 -0
- package/test/browser/test/compare_util.js +50 -0
- package/test/browser/test/html/canvas_basic.html +1 -0
- package/test/browser/test/html/div_basic.html +2 -0
- package/test/browser/test/html/event_dom_form.html +4 -0
- package/test/browser/test/html/event_dom_scrolldiv.html +5 -0
- package/test/browser/test/image/canvas_test1.png +0 -0
- package/test/browser/test/image/canvas_test2.png +0 -0
- package/test/browser/test/image/canvas_test3.png +0 -0
- package/test/browser/test/image/canvas_test4.png +0 -0
- package/test/browser/test/image/canvas_test7.png +0 -0
- package/test/browser/test/image/canvas_test8.png +0 -0
- package/test/browser/test/image/canvas_test_blank.png +0 -0
- package/test/browser/test/image/elephant_kana.png +0 -0
- package/test/browser/test/image/panda_kana.png +0 -0
- package/test/browser/test/image/turtle_kana.png +0 -0
- package/test/browser/test/import_plugin_checker.js +24 -0
- package/test/browser/test/plugin_browser_test.js +52 -0
- package/test/browser/test/plugin_browser_test_ajax.js +123 -0
- package/test/browser/test/plugin_browser_test_color.js +18 -0
- package/test/browser/test/plugin_browser_test_dialog.js +72 -0
- package/test/browser/test/plugin_browser_test_dom_event.js +598 -0
- package/test/browser/test/plugin_browser_test_dom_parts.js +125 -0
- package/test/browser/test/plugin_browser_test_system.js +9 -0
- package/test/browser/test/plugin_turtle_test.js +817 -0
- package/test/browser/test/plugin_webworker_test.js +87 -0
- package/test/browser/test/require_test.js +71 -0
- package/test/bundled/karma.config.base.js +117 -0
- package/test/bundled/karma.config.js +86 -0
- package/test/bundled/test/.babelrc.json +3 -0
- package/test/bundled/test/bundled_test.js +69 -0
- package/test/bundled/test/html/custom_context.html +65 -0
- package/test/bundled/test/html/custom_debug.html +66 -0
- package/test/bundled/test4b.cmd +52 -0
- package/test/bundled/test_base/.babelrc.json +3 -0
- package/test/bundled/test_base/_checktool_test.js +25 -0
- package/test/bundled/test_base/basic_ajax_test.js +56 -0
- package/test/bundled/test_base/basic_async_test.js +18 -0
- package/test/bundled/test_base/basic_test.js +153 -0
- package/test/bundled/test_base/calc_test.js +132 -0
- package/test/bundled/test_base/css/browsers_box.css +114 -0
- package/test/bundled/test_base/html/custom_context.html +69 -0
- package/test/bundled/test_base/html/custom_debug.html +71 -0
- package/test/bundled/test_base/js/browsers_box.js +72 -0
- package/test/bundled/test_base/plugin_csv_test.js +37 -0
- package/test/bundled/test_base/plugin_datetime_test.js +115 -0
- package/test/bundled/test_base/plugin_kansuji_test.js +49 -0
- package/test/bundled/test_base/plugin_system_test.js +410 -0
- package/test/bundled/test_base/plugin_webworker_test.js +53 -0
- package/test/bundled/test_base/resources/ok.txt +1 -0
- package/test/bundled/test_base/test_utils.js +191 -0
- package/test/common/array_test.js +40 -0
- package/test/common/basic_test.js +317 -0
- package/test/common/calc_test.js +139 -0
- package/test/common/debug_test.js +16 -0
- package/test/common/error_test.js +16 -0
- package/test/common/flow_test.js +360 -0
- package/test/common/func_call.js +136 -0
- package/test/common/func_test.js +149 -0
- package/test/common/indent_test.js +362 -0
- package/test/common/lex_test.js +146 -0
- package/test/common/literal_test.js +72 -0
- package/test/common/nako_logger_test.js +26 -0
- package/test/common/plugin_browser_test.js +24 -0
- package/test/common/plugin_browser_ut_audio_test.js +88 -0
- package/test/common/plugin_browser_ut_color_test.js +21 -0
- package/test/common/plugin_browser_ut_dialog_test.js +100 -0
- package/test/common/plugin_browser_ut_html_test.js +13 -0
- package/test/common/plugin_browser_ut_system_test.js +10 -0
- package/test/common/plugin_csv_test.js +39 -0
- package/test/common/plugin_datetime_test.js +120 -0
- package/test/common/plugin_kansuji_test.js +59 -0
- package/test/common/plugin_promise_test.js +18 -0
- package/test/common/plugin_system_test.js +451 -0
- package/test/common/prepare_test.js +93 -0
- package/test/common/re_test.js +20 -0
- package/test/common/variable_scope_test.js +105 -0
- package/test/jsconfig.json +19 -0
- package/test/karma.config.js +91 -0
- package/test/node/add_test.nako3 +1 -0
- package/test/node/async_test.js +80 -0
- package/test/node/commander_ja_test.js +82 -0
- package/test/node/error_message_test.js +244 -0
- package/test/node/kai_test.nako3 +6 -0
- package/test/node/node_test.js +43 -0
- package/test/node/plugin_broken.js.txt +3 -0
- package/test/node/plugin_browser_ut_ajax_test.js +355 -0
- package/test/node/plugin_browser_ut_location_test.js +32 -0
- package/test/node/plugin_markup_test.js +44 -0
- package/test/node/plugin_math_test.js +42 -0
- package/test/node/plugin_node_test.js +93 -0
- package/test/node/plugin_test.js +16 -0
- package/test/node/relative_import_test_1.nako3 +1 -0
- package/test/node/relative_import_test_2.nako3 +2 -0
- package/test/node/require_nako3_test.js +59 -0
- package/test/node/requiretest.nako3 +4 -0
- package/test/node/requiretest_indirect.nako3 +1 -0
- package/test/node/requiretest_name.nako3 +5 -0
- package/test/node/runtime_error.nako3 +2 -0
- package/test/node/side_effects_test.js +106 -0
- package/test/node/sjis.txt +5 -0
- package/test/node/syntax_error.nako3 +2 -0
- package/test/node/wnako3_editor_test.js +360 -0
- package/tools/README.md +7 -0
- package/tools/nako3edit/html/edit.html +83 -0
- package/tools/nako3edit/html/edit_plugin.js +6 -0
- package/tools/nako3edit/html/files.html +49 -0
- package/tools/nako3edit/html/nako3edit.css +66 -0
- package/tools/nako3edit/index.nako3 +145 -0
- package/tools/nako3edit/run.js +12 -0
- package/tools/nako3server/html/edit.html +104 -0
- package/tools/nako3server/html/edit_plugin.js +6 -0
- package/tools/nako3server/html/files.html +53 -0
- package/tools/nako3server/html/nako3edit.css +66 -0
- package/tools/nako3server/index.nako3 +129 -0
- package/tools/nako3server/run.js +12 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const assert = require('assert')
|
|
2
|
+
const NakoCompiler = require('../../src/nako3')
|
|
3
|
+
const { expect } = require('chai')
|
|
4
|
+
|
|
5
|
+
describe('array_test', () => {
|
|
6
|
+
const nako = new NakoCompiler()
|
|
7
|
+
const cmp = (/** @type {string} */code, /** @type {string} */res) => {
|
|
8
|
+
nako.logger.debug('code=' + code)
|
|
9
|
+
assert.strictEqual(nako.run(code, '').log, res)
|
|
10
|
+
}
|
|
11
|
+
const cmpNakoFuncs = (/** @type {string} */code, /** @type {Set<string>} */res) => {
|
|
12
|
+
nako.logger.debug('code=' + code)
|
|
13
|
+
nako.run(code, '')
|
|
14
|
+
assert.deepStrictEqual(nako.usedFuncs, res)
|
|
15
|
+
}
|
|
16
|
+
// --- test ---
|
|
17
|
+
it('配列の基本テスト', () => {
|
|
18
|
+
cmp('A=[0,1,2];A[0]を表示', '0')
|
|
19
|
+
cmp('A=[0,1,2];A@1を表示', '1')
|
|
20
|
+
})
|
|
21
|
+
it('二次元配列の参照 A[1][1]', () => {
|
|
22
|
+
cmp('A=[[0,1,2],[3,4,5]];A[1][1]を表示', '4')
|
|
23
|
+
})
|
|
24
|
+
it('二次元配列の参照 A@1,1 #976 #1000', () => {
|
|
25
|
+
cmp('A=[[0,1,2],[3,4,5]];A@1,1を表示', '4')
|
|
26
|
+
})
|
|
27
|
+
it('二次元配列@の参照 #976', () => {
|
|
28
|
+
cmp('A=[[0,1,2],[3,4,5]];A@1@1を表示', '4')
|
|
29
|
+
cmp('A=[[0,1,2],[3,4,5]];A@1,1を表示', '4')
|
|
30
|
+
cmp('A=[[0,1,2],[3,4,5]];N,M=[1,1];A@N,Mを表示', '4')
|
|
31
|
+
})
|
|
32
|
+
it('二次元配列の代入 #976', () => {
|
|
33
|
+
cmp('A=[[0,1,2],[3,4,5]];A[1][1]=100;A[1][1]を表示', '100')
|
|
34
|
+
cmp('A=[[0,1,2],[3,4,5]];N=1;M=1;A@N,M=100;A@N,Mを表示', '100')
|
|
35
|
+
cmp('A=[[0,1,2],[3,4,5]];A[1][1]を表示', '4')
|
|
36
|
+
})
|
|
37
|
+
it('要素から配列を記述する際に明示的な()が必要になる不具合 #1000', () => {
|
|
38
|
+
cmp('Aは[0,1,2];Bは[A[1], A[1], A[2]];B[1]を表示', '1')
|
|
39
|
+
})
|
|
40
|
+
})
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
const assert = require('assert')
|
|
2
|
+
const NakoCompiler = require('../../src/nako3')
|
|
3
|
+
const { expect } = require('chai')
|
|
4
|
+
|
|
5
|
+
describe('basic', () => {
|
|
6
|
+
const nako = new NakoCompiler()
|
|
7
|
+
// nako.logger.addListener('trace', ({ browserConsole }) => { console.log(...browserConsole) })
|
|
8
|
+
const cmp = (/** @type {string} */code, /** @type {string} */res) => {
|
|
9
|
+
nako.logger.debug('code=' + code)
|
|
10
|
+
assert.strictEqual(nako.run(code, '').log, res)
|
|
11
|
+
}
|
|
12
|
+
const cmpNakoFuncs = (/** @type {string} */code, /** @type {Set<string>} */res) => {
|
|
13
|
+
nako.logger.debug('code=' + code)
|
|
14
|
+
nako.run(code, '')
|
|
15
|
+
assert.deepStrictEqual(nako.usedFuncs, res)
|
|
16
|
+
}
|
|
17
|
+
// --- test ---
|
|
18
|
+
it('print simple', () => {
|
|
19
|
+
cmp('3を表示', '3')
|
|
20
|
+
})
|
|
21
|
+
it('print', () => {
|
|
22
|
+
cmp('3を表示', '3')
|
|
23
|
+
cmp('100を表示', '100')
|
|
24
|
+
cmp('0xFFを表示', '255')
|
|
25
|
+
})
|
|
26
|
+
it('string', () => {
|
|
27
|
+
cmp('「abc」を表示', 'abc')
|
|
28
|
+
cmp('"abc"を表示', 'abc')
|
|
29
|
+
cmp('“あいう”を表示', 'あいう')
|
|
30
|
+
})
|
|
31
|
+
it('rawstring', () => {
|
|
32
|
+
cmp('『abc』を表示', 'abc')
|
|
33
|
+
cmp('\'abc\'を表示', 'abc')
|
|
34
|
+
cmp('『abc{30}abc』を表示', 'abc{30}abc')
|
|
35
|
+
})
|
|
36
|
+
it('exstring', () => {
|
|
37
|
+
cmp('a=30;「abc{a}abc」を表示', 'abc30abc')
|
|
38
|
+
cmp('a=30;「abc{a}abc」を表示', 'abc30abc')
|
|
39
|
+
})
|
|
40
|
+
it('raw string - 🌿 .. 🌿', () => {
|
|
41
|
+
cmp('a=🌿abc🌿;aを表示', 'abc')
|
|
42
|
+
})
|
|
43
|
+
it('EX string - 🌴 .. 🌴', () => {
|
|
44
|
+
cmp('v=30;a=🌴abc{v}abc🌴;aを表示', 'abc30abc')
|
|
45
|
+
})
|
|
46
|
+
it('string - LF', () => {
|
|
47
|
+
cmp('a=30;「abc\nabc」を表示', 'abc\nabc')
|
|
48
|
+
})
|
|
49
|
+
it('space 「・」', () => {
|
|
50
|
+
cmp('・a=30;・b=50「{a}-{b}」を表示', '30-50')
|
|
51
|
+
})
|
|
52
|
+
it('string - 🌴 ... 🌴', () => {
|
|
53
|
+
cmp('🌴aaa🌴を表示', 'aaa')
|
|
54
|
+
cmp('a=30;🌴aaa{a}bbb🌴を表示', 'aaa30bbb')
|
|
55
|
+
cmp('a=30;🌿aaa{a}bbb🌿を表示', 'aaa{a}bbb')
|
|
56
|
+
})
|
|
57
|
+
it('システム定数', () => {
|
|
58
|
+
cmp('ナデシコエンジンを表示', 'nadesi.com/v3')
|
|
59
|
+
})
|
|
60
|
+
it('助詞の後に句読点', () => {
|
|
61
|
+
cmp('「こんにちは」と、表示。', 'こんにちは')
|
|
62
|
+
})
|
|
63
|
+
it('代入文', () => {
|
|
64
|
+
cmp('3000を値段に代入。値段を表示', '3000')
|
|
65
|
+
cmp('値段に3000を代入。値段を表示', '3000')
|
|
66
|
+
cmp('々=3000。々を表示', '3000')
|
|
67
|
+
cmp('々に3000を代入。々を表示', '3000')
|
|
68
|
+
})
|
|
69
|
+
it('連文後の代入文', () => {
|
|
70
|
+
cmp('「aabbcc」の「aa」を「」に置換してFに代入。Fを表示', 'bbcc')
|
|
71
|
+
cmp('「aabbcc」の「aa」を「」に置換して「bb」を「」に置換してFに代入。Fを表示', 'cc')
|
|
72
|
+
})
|
|
73
|
+
it('〜を〜に定める', () => {
|
|
74
|
+
cmp('Aを0.8に定めてAを表示', '0.8')
|
|
75
|
+
})
|
|
76
|
+
it('文字列 - &と改行', () => {
|
|
77
|
+
cmp('「aaa」& _\n「bbb」を表示。', 'aaabbb')
|
|
78
|
+
cmp('A= 1 + 1 + 1 + 1 + 1 + _\n1 + 1\nAを表示', '7')
|
|
79
|
+
cmp('A= 1 + 1 + 1 + 1 + 1 + _\r\n1 + 1 + 1\r\nAを表示', '8')
|
|
80
|
+
cmp('A= 1 + 1 + 1 + 1 + 1 + _ \r\n1 + 3 \r\nAを表示', '9')
|
|
81
|
+
cmp('A = 1 + _\n' +
|
|
82
|
+
' 5 + _\n' +
|
|
83
|
+
' 10\n' +
|
|
84
|
+
'Aを表示。', '16')
|
|
85
|
+
})
|
|
86
|
+
it('名前に数字を持つ変数を使う', () => {
|
|
87
|
+
cmp('A1=30;B1=20;「{A1}{B1}」を表示。', '3020')
|
|
88
|
+
})
|
|
89
|
+
it('名前に絵文字を持つ変数を使う', () => {
|
|
90
|
+
cmp('\u1F60=30;\u1F60を表示。', '30')
|
|
91
|
+
cmp('😄=30;😄を表示。', '30')
|
|
92
|
+
})
|
|
93
|
+
it('ラインコメントが正しく処理されない問題 (#112)', () => {
|
|
94
|
+
cmp('A=50 # hogehoge\nAを表示', '50')
|
|
95
|
+
cmp('A=50 # hogehoge\nAを表示', '50')
|
|
96
|
+
cmp('A=50 ※ hogehoge\nAを表示', '50')
|
|
97
|
+
cmp('A=50 // hogehoge\nAを表示', '50')
|
|
98
|
+
cmp('A=50 // hogehoge\nAを表示', '50')
|
|
99
|
+
cmp('A=50\nもしA=50ならば # hogehoge\nAを表示\nここまで\n', '50')
|
|
100
|
+
cmp('A=50\nもしA=50ならば # hogehoge\nAを表示\nここまで\n', '50')
|
|
101
|
+
cmp('A=50\nもしA=50ならば ※ hogehoge\nAを表示\nここまで\n', '50')
|
|
102
|
+
cmp('A=50\nもしA=50ならば // hogehoge\nAを表示\nここまで\n', '50')
|
|
103
|
+
cmp('A=50\nもしA=50ならば // hogehoge\nAを表示\nここまで\n', '50')
|
|
104
|
+
})
|
|
105
|
+
it('ラインコメントに文字列記号があり閉じていないとエラーになる(#725)', () => {
|
|
106
|
+
cmp('A=50 # \"hogehoge\nAを表示', '50')
|
|
107
|
+
})
|
|
108
|
+
it('範囲コメントに文字列記号があり閉じていないとエラーになる(#731)', () => {
|
|
109
|
+
cmp('A=50 /* " */Aを表示', '50')
|
|
110
|
+
cmp('A=50 /* \' */Aを表示', '50')
|
|
111
|
+
})
|
|
112
|
+
it('usedFuncs', () => {
|
|
113
|
+
cmpNakoFuncs('●({関数}fでaを)演算処理とは;それは、f(a);ここまで;●(aを)二倍処理とは;それはa*2;ここまで;二倍処理で2を演算処理して表示', new Set(['表示']))
|
|
114
|
+
})
|
|
115
|
+
it('論文などで使われる句読点「,」を「、」(#735)', () => {
|
|
116
|
+
cmp('A1=30;B1=20;(A1+B1)を,表示', '50')
|
|
117
|
+
cmp('A=3.14;Aを,表示', '3.14')
|
|
118
|
+
})
|
|
119
|
+
it('条件分岐のインデント構文', () => {
|
|
120
|
+
cmp(
|
|
121
|
+
'!インデント構文\n' +
|
|
122
|
+
'3で条件分岐\n' +
|
|
123
|
+
' 2ならば\n' +
|
|
124
|
+
' 1を表示\n' +
|
|
125
|
+
' 3ならば\n' +
|
|
126
|
+
' 2を表示\n' +
|
|
127
|
+
' 違えば\n' +
|
|
128
|
+
' 3を表示\n',
|
|
129
|
+
'2'
|
|
130
|
+
)
|
|
131
|
+
})
|
|
132
|
+
it('独立した助詞『ならば』の位置の取得', () => {
|
|
133
|
+
const out = nako.lex('もし存在するならば\nここまで', '')
|
|
134
|
+
const sonzai = out.tokens.find((t) => t.value === '存在')
|
|
135
|
+
const naraba = out.tokens.find((t) => t.type === 'ならば')
|
|
136
|
+
|
|
137
|
+
// 「存在する」
|
|
138
|
+
expect(sonzai).to.have.property("startOffset").and.to.equal(2)
|
|
139
|
+
expect(sonzai).to.have.property("endOffset").and.to.equal(6)
|
|
140
|
+
|
|
141
|
+
// ならば
|
|
142
|
+
expect(naraba).to.have.property("startOffset").and.to.equal(6)
|
|
143
|
+
expect(naraba).to.have.property("endOffset").and.to.equal(9)
|
|
144
|
+
})
|
|
145
|
+
it('preCodeを考慮したソースマップ', () => {
|
|
146
|
+
const preCode = '1を表示\n2を表示\n3を'
|
|
147
|
+
const tokens = nako.lex(preCode + '表示', 'main.nako3', preCode).tokens
|
|
148
|
+
|
|
149
|
+
// '3' は-2から0文字目
|
|
150
|
+
const three = tokens.findIndex((t) => t.value === 3)
|
|
151
|
+
assert.strictEqual(tokens[three].startOffset, -2)
|
|
152
|
+
assert.strictEqual(tokens[three].endOffset, 0)
|
|
153
|
+
assert.strictEqual(tokens[three].line, 0)
|
|
154
|
+
assert.strictEqual(tokens[three].column, -2)
|
|
155
|
+
|
|
156
|
+
// '表示' は0~1文字目
|
|
157
|
+
assert.strictEqual(tokens[three + 1].startOffset, 0)
|
|
158
|
+
assert.strictEqual(tokens[three + 1].endOffset, 2)
|
|
159
|
+
assert.strictEqual(tokens[three + 1].line, 0)
|
|
160
|
+
assert.strictEqual(tokens[three + 1].column, 0)
|
|
161
|
+
})
|
|
162
|
+
it('実行速度優先 - 1行のみ', () => {
|
|
163
|
+
nako.reset()
|
|
164
|
+
cmp(`
|
|
165
|
+
「全て」で実行速度優先して1を表示
|
|
166
|
+
「全て」で実行速度優先して2を表示
|
|
167
|
+
`, '1\n2')
|
|
168
|
+
})
|
|
169
|
+
it('実行速度優先 - ブロック内に適用', () => {
|
|
170
|
+
// エラーが起きなければ、「実行速度優先」が無い場合と同じ動作をする。
|
|
171
|
+
cmp(`\
|
|
172
|
+
「全て」で実行速度優先
|
|
173
|
+
●Fとは
|
|
174
|
+
2を表示
|
|
175
|
+
3を表示
|
|
176
|
+
ここまで
|
|
177
|
+
1を表示
|
|
178
|
+
F
|
|
179
|
+
ここまで
|
|
180
|
+
4を表示
|
|
181
|
+
`, '1\n2\n3\n4')
|
|
182
|
+
})
|
|
183
|
+
it('実行速度優先 - 関数宣言の上方下方参照', () => {
|
|
184
|
+
// エラーが起きなければ、「実行速度優先」が無い場合と同じ動作をする。
|
|
185
|
+
cmp(`\
|
|
186
|
+
「全て」で実行速度優先
|
|
187
|
+
●Gとは
|
|
188
|
+
2を表示
|
|
189
|
+
3を表示
|
|
190
|
+
ここまで
|
|
191
|
+
●Fとは
|
|
192
|
+
Eする
|
|
193
|
+
ここまで
|
|
194
|
+
●Eとは
|
|
195
|
+
Gする
|
|
196
|
+
ここまで
|
|
197
|
+
1を表示
|
|
198
|
+
F
|
|
199
|
+
ここまで
|
|
200
|
+
4を表示
|
|
201
|
+
`, '1\n2\n3\n4')
|
|
202
|
+
})
|
|
203
|
+
it('空白で区切って文をつなげた場合', () => {
|
|
204
|
+
cmp('1と2を足す 1と2を足す', '')
|
|
205
|
+
})
|
|
206
|
+
it('return_none: true のaddFuncで定義した関数が「それ」に値を代入しないことを確認する', () => {
|
|
207
|
+
const nako = new NakoCompiler()
|
|
208
|
+
nako.addFunc('hoge', [], () => {}, true)
|
|
209
|
+
assert.strictEqual(nako.run('1と2を足す\nhoge\nそれを表示', '').log, '3')
|
|
210
|
+
})
|
|
211
|
+
it('制御構文で一語関数を使う', () => {
|
|
212
|
+
cmp('●一とは\n1を戻す\nここまで\nもし一ならば\n1を表示\nここまで', '1') // if
|
|
213
|
+
cmp('●一とは\n1を戻す\nここまで\n一回\n1を表示\nここまで', '1') // times
|
|
214
|
+
cmp('●一とは\n1を戻す\nここまで\n一の間\n1を表示\n抜ける\nここまで', '1') // while
|
|
215
|
+
cmp('●一とは\n[1]を戻す\nここまで\n一を反復\n1を表示\nここまで', '1') // foreach
|
|
216
|
+
cmp('●一とは\n1を戻す\nここまで\n一で条件分岐\n1ならば\n1を表示\nここまで\nここまで', '1') // switch
|
|
217
|
+
})
|
|
218
|
+
it('そう', () => {
|
|
219
|
+
// 「そう」は「それ」のエイリアス
|
|
220
|
+
cmp('それ=1;そうを表示', '1')
|
|
221
|
+
cmp('1に3を足す;そうを表示', '4')
|
|
222
|
+
})
|
|
223
|
+
it('「〜時間」の「間」を制御構文として認識させない #831', () => {
|
|
224
|
+
cmp('時間=1\n(時間)を表示', '1')
|
|
225
|
+
})
|
|
226
|
+
it('「もしFが存在するならば」がFと「存在する」の比較になる問題の修正 #830', () => {
|
|
227
|
+
cmp('●(Aが)hogeとは\n' +
|
|
228
|
+
' 1を戻す\n' +
|
|
229
|
+
'ここまで\n' +
|
|
230
|
+
'もし、Fがhogeならば\n' +
|
|
231
|
+
' 1を表示\n' +
|
|
232
|
+
'ここまで',
|
|
233
|
+
// ---
|
|
234
|
+
'1')
|
|
235
|
+
})
|
|
236
|
+
it('無名関数が警告を出す問題の修正 #841', () => {
|
|
237
|
+
let log = ''
|
|
238
|
+
nako.logger.addListener('warn', ({ noColor }) => { log += noColor })
|
|
239
|
+
nako.parse(
|
|
240
|
+
'f = 関数(x) それは、x。ここまで。\n' +
|
|
241
|
+
'g = 関数(x) それは、x。ここまで。\n'
|
|
242
|
+
, 'main.nako3')
|
|
243
|
+
assert.strictEqual(log, '')
|
|
244
|
+
})
|
|
245
|
+
it('単独で実行できるプログラムの出力', function (done) {
|
|
246
|
+
if (typeof process === 'undefined' || process.env.NODE_ENV === 'test') {return this.skip()}
|
|
247
|
+
const code = nako.compileStandalone('1+2を表示', 'main.nako3', false)
|
|
248
|
+
Function('const console = { log: this.callback };\n' + code).apply({
|
|
249
|
+
callback: (/** @type {any} */text) => {
|
|
250
|
+
assert.strictEqual(text, '3')
|
|
251
|
+
done()
|
|
252
|
+
},
|
|
253
|
+
})
|
|
254
|
+
})
|
|
255
|
+
it('resetされた後に関数名を取得できない問題の修正 #849', (done) => {
|
|
256
|
+
const nako = new NakoCompiler()
|
|
257
|
+
nako.logger.addListener('stdout', ({ noColor }) => {
|
|
258
|
+
assert(noColor.includes('function')) // JavaScriptのコード function() { var ... } が表示されるはず
|
|
259
|
+
done()
|
|
260
|
+
})
|
|
261
|
+
nako.run(`
|
|
262
|
+
●Aとは
|
|
263
|
+
ここまで
|
|
264
|
+
0.0001秒後には
|
|
265
|
+
「A」のJSオブジェクト取得して表示
|
|
266
|
+
ここまで。
|
|
267
|
+
`, '')
|
|
268
|
+
nako.reset()
|
|
269
|
+
console.log(nako.compile(`\
|
|
270
|
+
●テスト:足すとは
|
|
271
|
+
1と2を足す
|
|
272
|
+
それと3がASSERT等しい
|
|
273
|
+
ここまで
|
|
274
|
+
|
|
275
|
+
●テスト:引くとは
|
|
276
|
+
1と2を足す
|
|
277
|
+
それと3がASSERT等しい
|
|
278
|
+
ここまで
|
|
279
|
+
`, 'main.nako3', true))
|
|
280
|
+
})
|
|
281
|
+
//
|
|
282
|
+
it('「AはBである」構文 #939', () => {
|
|
283
|
+
cmp('Aは9である。Aを表示', '9')
|
|
284
|
+
cmp('Bは「あ」である。Bを表示', 'あ')
|
|
285
|
+
cmp('Cは[1,2,3]である;C[2]を表示', '3')
|
|
286
|
+
})
|
|
287
|
+
it('「AはBです」構文 #974', () => {
|
|
288
|
+
cmp('Aは9です。Aを表示', '9')
|
|
289
|
+
cmp('Bは「あ」でした。Bを表示してください。', 'あ')
|
|
290
|
+
cmp('Cは[1,2,3]である;C[2]を表示', '3')
|
|
291
|
+
})
|
|
292
|
+
it('複数変数代入構文 #563', () => {
|
|
293
|
+
cmp('A,B=[1,2];Aを表示;Bを表示', '1\n2')
|
|
294
|
+
cmp('A,B,C=[1,2,3];Aを表示;Bを表示;Cを表示', '1\n2\n3')
|
|
295
|
+
cmp('A,B=[1];Aを表示;Bを表示;', '1\nundefined')
|
|
296
|
+
cmp('A,B,C,D=[1,2,3,4];Dを表示;', '4')
|
|
297
|
+
})
|
|
298
|
+
it('複数定数代入構文 #563', () => {
|
|
299
|
+
cmp('定数[A,B]=[1,2];Aを表示;Bを表示', '1\n2')
|
|
300
|
+
cmp('定数[A,B,C]=[1,2,3];Aを表示;Bを表示;Cを表示', '1\n2\n3')
|
|
301
|
+
cmp('定数[A,B]=[1];Aを表示;Bを表示;', '1\nundefined')
|
|
302
|
+
cmp('定数[A,B,C,D]=[1,2,3,4];Dを表示;', '4')
|
|
303
|
+
})
|
|
304
|
+
it('複数定数代入構文その2 #563', () => {
|
|
305
|
+
cmp('変数[A,B]=[1,2];Aを表示;Bを表示', '1\n2')
|
|
306
|
+
cmp('変数[A,B,C]=[1,2,3];Aを表示;Bを表示;Cを表示', '1\n2\n3')
|
|
307
|
+
cmp('変数[A,B]=[1];Aを表示;Bを表示;', '1\nundefined')
|
|
308
|
+
cmp('変数[A,B,C,D]=[1,2,3,4];Dを表示;', '4')
|
|
309
|
+
})
|
|
310
|
+
it('複数代入文の問題 #1027', () => {
|
|
311
|
+
cmp('塊=[[0,0],[1,1]];塊を反復\nx,y=対象;💧;塊をJSONエンコードして表示。', '[[0,0],[1,1]]')
|
|
312
|
+
cmp('x=1;y=2;x,y=[y,x];xを表示', '2')
|
|
313
|
+
})
|
|
314
|
+
it('もし文で「ならば」の前の空行でエラー #1079', () => {
|
|
315
|
+
cmp('A=5;もし、A > 3 ならば「OK」と表示;', 'OK')
|
|
316
|
+
})
|
|
317
|
+
})
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
const assert = require('assert')
|
|
2
|
+
const NakoCompiler = require('../../src/nako3')
|
|
3
|
+
|
|
4
|
+
describe('calc_test.js', () => {
|
|
5
|
+
const nako = new NakoCompiler()
|
|
6
|
+
// nako.logger.addListener('trace', ({ browserConsole }) => { console.log(...browserConsole) })
|
|
7
|
+
const cmp = (code, res) => {
|
|
8
|
+
if (nako.debug) {
|
|
9
|
+
console.log('code=' + code)
|
|
10
|
+
}
|
|
11
|
+
assert.strictEqual(nako.run(code).log, res)
|
|
12
|
+
}
|
|
13
|
+
it('basic', () => {
|
|
14
|
+
cmp('3を表示', '3')
|
|
15
|
+
cmp('3.14を表示', '3.14')
|
|
16
|
+
cmp('0.5e+3を表示', '500')
|
|
17
|
+
})
|
|
18
|
+
it('足し算', () => {
|
|
19
|
+
cmp('3+5を表示', '8')
|
|
20
|
+
})
|
|
21
|
+
it('引き算', () => {
|
|
22
|
+
cmp('10-5を表示。', '5')
|
|
23
|
+
cmp('10-5を表示。', '5')
|
|
24
|
+
})
|
|
25
|
+
it('掛け算', () => {
|
|
26
|
+
cmp('1+2*3を表示', '7')
|
|
27
|
+
})
|
|
28
|
+
it('連続演算:して', () => {
|
|
29
|
+
cmp('3に5を足して表示', '8')
|
|
30
|
+
})
|
|
31
|
+
it('連続演算:て-3に5を掛けて表示', () => {
|
|
32
|
+
cmp('3に5を掛けて表示', '15')
|
|
33
|
+
})
|
|
34
|
+
it('配列', () => {
|
|
35
|
+
cmp('a=[];a[1]=30;a[1]を表示', '30')
|
|
36
|
+
cmp('a=[];a【1】=30;a[1]を表示', '30')
|
|
37
|
+
})
|
|
38
|
+
it('ネスト配列', () => {
|
|
39
|
+
cmp('a=[[1,2,3], [4,5,6]];a[1][1]を表示', '5')
|
|
40
|
+
})
|
|
41
|
+
it('ネスト配列で、マイナスを含むときのバグ修正 (#276)', () => {
|
|
42
|
+
cmp('a=[-1, -2, -3];a[0]を表示', '-1')
|
|
43
|
+
cmp('a=[-1, -2, -3];a[2]を表示', '-3')
|
|
44
|
+
cmp('a=[[-1, -1], [1, -1]];a[0][0]を表示', '-1')
|
|
45
|
+
})
|
|
46
|
+
it('オブジェクト', () => {
|
|
47
|
+
cmp('a={};a[\'a\']=30;a[\'a\']を表示', '30')
|
|
48
|
+
})
|
|
49
|
+
it('階乗', () => {
|
|
50
|
+
cmp('2^3を表示', '8')
|
|
51
|
+
})
|
|
52
|
+
it('否定', () => {
|
|
53
|
+
cmp('(!1)を表示', '0')
|
|
54
|
+
cmp('(!0)を表示', '1')
|
|
55
|
+
cmp('(!オン)を表示', '0')
|
|
56
|
+
cmp('(!オフ)を表示', '1')
|
|
57
|
+
})
|
|
58
|
+
it('配列簡易記号', () => {
|
|
59
|
+
cmp('A=[];A@0=5;A@0を表示', '5')
|
|
60
|
+
cmp('A=[];A@0=5;A@1=6;AをJSONエンコードして表示', '[5,6]')
|
|
61
|
+
})
|
|
62
|
+
it('JSON配列-改行あり', () => {
|
|
63
|
+
cmp('A=[\n0,\n1,\n2,\n3];A@2を表示', '2')
|
|
64
|
+
})
|
|
65
|
+
it('JSON配列-カンマ省略', () => {
|
|
66
|
+
cmp('A=[1 2 3 4 5];AをJSONエンコードして表示', '[1,2,3,4,5]')
|
|
67
|
+
})
|
|
68
|
+
it('JSON配列-ネスト', () => {
|
|
69
|
+
cmp('A=[[1,2,3],[4,5,6]];AをJSONエンコードして表示', '[[1,2,3],[4,5,6]]')
|
|
70
|
+
})
|
|
71
|
+
it('JSONオブジェクト-改行あり', () => {
|
|
72
|
+
cmp('A={\n"殿":"男","姫":"女"\n};A@"殿"を表示', '男')
|
|
73
|
+
})
|
|
74
|
+
it('JSONオブジェクト-値を省略した場合', () => {
|
|
75
|
+
cmp('N={"hoge"};N["hoge"]を表示。', 'hoge')
|
|
76
|
+
cmp('N={"hoge","fuga","bar"};N["bar"]を表示。', 'bar')
|
|
77
|
+
cmp('N={32,45,66};N[45]を表示。', '45')
|
|
78
|
+
})
|
|
79
|
+
it('JSONオブジェクト-キーを文字列で囲わなかった場合', () => {
|
|
80
|
+
cmp('N={hoge:30};N["hoge"]を表示。', '30')
|
|
81
|
+
})
|
|
82
|
+
it('文字列→数値への暗黙的変換', () => {
|
|
83
|
+
cmp('A="5";B="50";A+Bを表示', '55')
|
|
84
|
+
cmp('"100"/"2"を表示', '50')
|
|
85
|
+
cmp('"2"*"3"を表示', '6')
|
|
86
|
+
cmp('"100"%"10"を表示', '0')
|
|
87
|
+
})
|
|
88
|
+
it('空配列テスト', () => {
|
|
89
|
+
cmp('A=空配列;A@0=30;A@1=50;Aを「:」で配列結合して表示', '30:50')
|
|
90
|
+
cmp('A=空配列;B=空配列;A@0=30;A@1=50;B@0=1;Bを「:」で配列結合して表示', '1')
|
|
91
|
+
})
|
|
92
|
+
it('単項演算子 minus number', () => {
|
|
93
|
+
cmp('-1*5を表示', '-5')
|
|
94
|
+
cmp('5*-1を表示', '-5')
|
|
95
|
+
})
|
|
96
|
+
it('単項演算子 minus word', () => {
|
|
97
|
+
cmp('A=1;5*-Aを表示', '-5')
|
|
98
|
+
})
|
|
99
|
+
it('論理演算', () => {
|
|
100
|
+
cmp('BMI=25;A=((25 ≦ BMI) かつ (BMI < 30));Aを表示', 'true')
|
|
101
|
+
cmp('BMI=25;A=((18.5 > BMI) または (BMI > 30));Aを表示', 'false')
|
|
102
|
+
})
|
|
103
|
+
it('カッコ内の関数呼び出し', () => {
|
|
104
|
+
cmp('N=("ABC"の文字数);Nを表示。', '3')
|
|
105
|
+
})
|
|
106
|
+
it('文字列の埋め込み変数加算', () => {
|
|
107
|
+
cmp('N1=30;「--{N1+1}--」を表示', '--31--')
|
|
108
|
+
})
|
|
109
|
+
it('文字列の埋め込み変数減算', () => {
|
|
110
|
+
cmp('N1=30;「--{N1-1}--」を表示', '--29--')
|
|
111
|
+
})
|
|
112
|
+
it('文字列の埋め込み変数乗算', () => {
|
|
113
|
+
cmp('N1=30;「--{N1*2}--」を表示', '--60--')
|
|
114
|
+
})
|
|
115
|
+
it('文字列の埋め込み変数除算', () => {
|
|
116
|
+
cmp('N1=30;「--{N1/2}--」を表示', '--15--')
|
|
117
|
+
})
|
|
118
|
+
it('文字列の埋め込み変数剰余', () => {
|
|
119
|
+
cmp('N1=30;「--{N1%2}--」を表示', '--0--')
|
|
120
|
+
})
|
|
121
|
+
it('文字列の埋め込み変数冪乗', () => {
|
|
122
|
+
cmp('N1=2;「--{N1^3}--」を表示', '--8--')
|
|
123
|
+
})
|
|
124
|
+
it('比較演算子', () => {
|
|
125
|
+
cmp('A=1>5;Aを表示', 'false')
|
|
126
|
+
})
|
|
127
|
+
it('ビット演算', () => {
|
|
128
|
+
cmp('A=0xF0>>4;Aを表示', '15')
|
|
129
|
+
cmp('A=0xF<<4;Aを表示', '240')
|
|
130
|
+
})
|
|
131
|
+
it('連文で計算 (#729)', () => {
|
|
132
|
+
cmp('1に2を足して3を足して4を引いて5を掛けて2で割って表示', '5')
|
|
133
|
+
cmp('2に3を掛けて4を足して5で割って表示', '2')
|
|
134
|
+
})
|
|
135
|
+
it('厳格な比較 (#999)', () => {
|
|
136
|
+
cmp('N=「」;もし、N=0ならば「OK」と表示。', 'OK')
|
|
137
|
+
cmp('N=「」;もし、N===0ならば「NG」と表示。違えば「OK」と表示。', 'OK')
|
|
138
|
+
})
|
|
139
|
+
})
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const assert = require('assert')
|
|
2
|
+
const NakoCompiler = require('../../src/nako3')
|
|
3
|
+
|
|
4
|
+
describe('debug', () => {
|
|
5
|
+
const nako = new NakoCompiler()
|
|
6
|
+
// nako.logger.addListener('trace', ({ browserConsole }) => { console.log(...browserConsole) })
|
|
7
|
+
const cmp = (code, res) => {
|
|
8
|
+
nako.logger.debug('code=' + code)
|
|
9
|
+
assert.strictEqual(nako.run(code).log, res)
|
|
10
|
+
}
|
|
11
|
+
// --- test ---
|
|
12
|
+
it('print simple', () => {
|
|
13
|
+
cmp('/* aaa */\n3を表示\n2*3を表示', '3\n6')
|
|
14
|
+
// cmp("/* a\n */\n3を表示\n「テスト」でエラー発生。", "3\n6");
|
|
15
|
+
})
|
|
16
|
+
})
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const assert = require('assert')
|
|
2
|
+
const NakoCompiler = require('../../src/nako3')
|
|
3
|
+
|
|
4
|
+
describe('error_test', () => {
|
|
5
|
+
const nako = new NakoCompiler()
|
|
6
|
+
// nako.logger.addListener('trace', ({ browserConsole }) => { console.log(...browserConsole) })
|
|
7
|
+
const cmp = (code, res) => {
|
|
8
|
+
nako.logger.debug('code=' + code)
|
|
9
|
+
assert.strictEqual(nako.run(code).log, res)
|
|
10
|
+
}
|
|
11
|
+
// --- test ---
|
|
12
|
+
it('エラー処理 - 基本', () => {
|
|
13
|
+
cmp('123を表示', '123')
|
|
14
|
+
cmp('エラー監視;「hoge」のエラー発生;エラーならば;「ERR」と表示;ここまで', 'ERR')
|
|
15
|
+
})
|
|
16
|
+
})
|