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,88 @@
|
|
|
1
|
+
const td = require('testdouble')
|
|
2
|
+
const assert = require('assert').strict
|
|
3
|
+
const PluginBrowser = require('../../src/plugin_browser')
|
|
4
|
+
const { PluginUtHelper } = require('../../utils/plugin_ut_helper')
|
|
5
|
+
|
|
6
|
+
class StubAudio {
|
|
7
|
+
contructor () {
|
|
8
|
+
this.src = ''
|
|
9
|
+
this.eventid = ''
|
|
10
|
+
this.callback = function () {}
|
|
11
|
+
this.currentTime = 0
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
addEventListener (evt, func) {
|
|
15
|
+
this.callback = func
|
|
16
|
+
this.eventid = evt
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
describe('plugin_browser_audio', () => {
|
|
21
|
+
const cu = new PluginUtHelper(PluginBrowser)
|
|
22
|
+
|
|
23
|
+
describe('audio-open', () => {
|
|
24
|
+
const chkopen = (args, url, res) => {
|
|
25
|
+
const sys = {}
|
|
26
|
+
sys.__v0 = {}
|
|
27
|
+
global.window = {}
|
|
28
|
+
global.window.Audio = StubAudio
|
|
29
|
+
global.Audio = StubAudio
|
|
30
|
+
args.push(sys)
|
|
31
|
+
const obj = PluginBrowser['オーディオ開'].fn.apply(this, args)
|
|
32
|
+
assert.equal(obj.src, url)
|
|
33
|
+
}
|
|
34
|
+
it('オーディオ開', () => {
|
|
35
|
+
chkopen(['http://url'], 'http://url')
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
describe('audio-play', () => {
|
|
39
|
+
const chkplay = () => {
|
|
40
|
+
const sys = {}
|
|
41
|
+
sys.__v0 = {}
|
|
42
|
+
global.window = {}
|
|
43
|
+
global.window.Audio = StubAudio
|
|
44
|
+
global.Audio = StubAudio
|
|
45
|
+
const obj = PluginBrowser['オーディオ開'].fn.apply(this, ['http://url', sys])
|
|
46
|
+
const fakePlay = td.func('play')
|
|
47
|
+
obj.play = fakePlay
|
|
48
|
+
obj.currentTime = 234
|
|
49
|
+
PluginBrowser['オーディオ再生'].fn.apply(this, [obj, sys])
|
|
50
|
+
assert.equal(obj.currentTime, 234)
|
|
51
|
+
td.verify(fakePlay(), { times: 1 })
|
|
52
|
+
}
|
|
53
|
+
it('オーディオ再生', () => {
|
|
54
|
+
chkplay()
|
|
55
|
+
})
|
|
56
|
+
it('オーディオ再生 - noobj', () => {
|
|
57
|
+
cu.cmpfnex('オーディオ再生', [null, {}], 'Error', 'オーディオ再生する前に、オーディオ開くで音声ファイルを読み込んでください')
|
|
58
|
+
})
|
|
59
|
+
})
|
|
60
|
+
describe('audio-pause', () => {
|
|
61
|
+
const chkpause = (fnname, cur, pos, res) => {
|
|
62
|
+
const sys = {}
|
|
63
|
+
sys.__v0 = {}
|
|
64
|
+
global.window = {}
|
|
65
|
+
global.window.Audio = StubAudio
|
|
66
|
+
global.Audio = StubAudio
|
|
67
|
+
const obj = PluginBrowser['オーディオ開'].fn.apply(this, ['http://url', sys])
|
|
68
|
+
const fakePause = td.func('pause')
|
|
69
|
+
obj.pause = fakePause
|
|
70
|
+
obj.currentTime = cur
|
|
71
|
+
PluginBrowser[fnname].fn.apply(this, [obj, sys])
|
|
72
|
+
assert.equal(obj.currentTime, res)
|
|
73
|
+
td.verify(fakePause(), { times: 1 })
|
|
74
|
+
}
|
|
75
|
+
it('オーディオ停止', () => {
|
|
76
|
+
chkpause('オーディオ停止', 234, 456, 0)
|
|
77
|
+
})
|
|
78
|
+
it('オーディオ一時停止', () => {
|
|
79
|
+
chkpause('オーディオ一時停止', 234, 456, 234)
|
|
80
|
+
})
|
|
81
|
+
it('オーディオ停止 - noobj', () => {
|
|
82
|
+
cu.cmpfnex('オーディオ停止', [null, {}], 'Error', 'オーディオ停止する前に、オーディオ開くで音声ファイルを読み込んでください')
|
|
83
|
+
})
|
|
84
|
+
it('オーディオ一時停止 - noobj', () => {
|
|
85
|
+
cu.cmpfnex('オーディオ一時停止', [null, {}], 'Error', 'オーディオ一時停止する前に、オーディオ開くで音声ファイルを読み込んでください')
|
|
86
|
+
})
|
|
87
|
+
})
|
|
88
|
+
})
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const PluginBrowser = require('../../src/plugin_browser')
|
|
2
|
+
const { PluginUtHelper } = require('../../utils/plugin_ut_helper')
|
|
3
|
+
|
|
4
|
+
describe('plugin_browser_color', () => {
|
|
5
|
+
const cu = new PluginUtHelper(PluginBrowser)
|
|
6
|
+
|
|
7
|
+
it('RGB', () => {
|
|
8
|
+
cu.cmpifn('RGB', [255, 255, 255], '#FFffFf')
|
|
9
|
+
cu.cmpifn('RGB', [0, 0, 0], '#000000')
|
|
10
|
+
cu.cmpifn('RGB', [22, 25, 255], '#1619FF')
|
|
11
|
+
})
|
|
12
|
+
it('色混ぜる', () => {
|
|
13
|
+
cu.cmpifn('色混', [[255, 255, 255]], '#ffFFff')
|
|
14
|
+
})
|
|
15
|
+
it('色混ぜる - no args', () => {
|
|
16
|
+
cu.cmpfnex('色混', [], 'Error', '『色混ぜる』の引数には配列を指定します')
|
|
17
|
+
})
|
|
18
|
+
it('色混ぜる - no enoough args', () => {
|
|
19
|
+
cu.cmpfnex('色混', [[1, 2]], 'Error', '『色混ぜる』の引数には[RR,GG,BB]形式の配列を指定します')
|
|
20
|
+
})
|
|
21
|
+
})
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
const td = require('testdouble')
|
|
2
|
+
const assert = require('assert').strict
|
|
3
|
+
const PluginBrowser = require('../../src/plugin_browser')
|
|
4
|
+
|
|
5
|
+
describe('plugin_browser_dialog', () => {
|
|
6
|
+
describe('言う', () => {
|
|
7
|
+
const chkalert = (args, msg) => {
|
|
8
|
+
const fakeAlert = td.func('alert')
|
|
9
|
+
td.when(fakeAlert(msg)).thenReturn(undefined)
|
|
10
|
+
global.window = {}
|
|
11
|
+
global.window.alert = fakeAlert
|
|
12
|
+
global.alert = fakeAlert
|
|
13
|
+
PluginBrowser['言'].fn.apply(this, args)
|
|
14
|
+
td.verify(fakeAlert(td.matchers.anything()), { times: 1 })
|
|
15
|
+
td.reset()
|
|
16
|
+
}
|
|
17
|
+
it('言', () => {
|
|
18
|
+
chkalert(['あいうえお'], 'あいうえお')
|
|
19
|
+
})
|
|
20
|
+
})
|
|
21
|
+
describe('尋ねる', () => {
|
|
22
|
+
const chkprompt = (args, rtn, msg, res) => {
|
|
23
|
+
const fakePrompt = td.func('prompt')
|
|
24
|
+
td.when(fakePrompt(msg)).thenReturn(rtn)
|
|
25
|
+
global.window = {}
|
|
26
|
+
global.window.prompt = fakePrompt
|
|
27
|
+
global.prompt = fakePrompt
|
|
28
|
+
assert.equal(PluginBrowser['尋'].fn.apply(this, args), res)
|
|
29
|
+
td.verify(fakePrompt(td.matchers.anything()), { times: 1 })
|
|
30
|
+
td.reset()
|
|
31
|
+
}
|
|
32
|
+
it('尋 - 数値', () => {
|
|
33
|
+
chkprompt(['あいうえお'], '2000', 'あいうえお', 2000)
|
|
34
|
+
chkprompt(['あいうえお'], '1.23', 'あいうえお', 1.23)
|
|
35
|
+
chkprompt(['あいうえお'], '356', 'あいうえお', 356)
|
|
36
|
+
chkprompt(['あいうえお'], '3.14', 'あいうえお', 3.14)
|
|
37
|
+
})
|
|
38
|
+
it('尋 - 負数', () => {
|
|
39
|
+
chkprompt(['あいうえお'], '-5', 'あいうえお', -5)
|
|
40
|
+
chkprompt(['あいうえお'], '-12.5', 'あいうえお', -12.5)
|
|
41
|
+
chkprompt(['あいうえお'], '-20', 'あいうえお', -20)
|
|
42
|
+
chkprompt(['あいうえお'], '-1.92', 'あいうえお', -1.92)
|
|
43
|
+
})
|
|
44
|
+
it('尋 - 数値以外', () => {
|
|
45
|
+
chkprompt(['あいうえお'], 'abd', 'あいうえお', 'abd')
|
|
46
|
+
chkprompt(['あいうえお'], '123...456', 'あいうえお', '123...456')
|
|
47
|
+
chkprompt(['あいうえお'], '1.2.3', 'あいうえお', '1.2.3')
|
|
48
|
+
chkprompt(['あいうえお'], 'あかね', 'あいうえお', 'あかね')
|
|
49
|
+
})
|
|
50
|
+
it('尋 - キャンセル', () => {
|
|
51
|
+
const sys = { __v0: { 空: '' } }
|
|
52
|
+
chkprompt(['あいうえお', sys], null, 'あいうえお', '')
|
|
53
|
+
})
|
|
54
|
+
})
|
|
55
|
+
describe('文字尋ねる', () => {
|
|
56
|
+
const chkprompt = (args, rtn, msg, res) => {
|
|
57
|
+
const fakePrompt = td.func('prompt')
|
|
58
|
+
td.when(fakePrompt(msg)).thenReturn(rtn)
|
|
59
|
+
global.window = {}
|
|
60
|
+
global.window.prompt = fakePrompt
|
|
61
|
+
global.prompt = fakePrompt
|
|
62
|
+
assert.equal(PluginBrowser['文字尋'].fn.apply(this, args), res)
|
|
63
|
+
td.verify(fakePrompt(td.matchers.anything()), { times: 1 })
|
|
64
|
+
td.reset()
|
|
65
|
+
}
|
|
66
|
+
it('文字尋 - 数字', () => {
|
|
67
|
+
chkprompt(['あいうえお'], '2000', 'あいうえお', '2000')
|
|
68
|
+
chkprompt(['あいうえお'], '1.23', 'あいうえお', '1.23')
|
|
69
|
+
})
|
|
70
|
+
it('文字尋 - 負数の数字', () => {
|
|
71
|
+
chkprompt(['あいうえお'], '-5', 'あいうえお', '-5')
|
|
72
|
+
chkprompt(['あいうえお'], '-12.5', 'あいうえお', '-12.5')
|
|
73
|
+
})
|
|
74
|
+
it('文字尋 - 数字以外', () => {
|
|
75
|
+
chkprompt(['あいうえお'], 'abd', 'あいうえお', 'abd')
|
|
76
|
+
chkprompt(['あいうえお'], '123...456', 'あいうえお', '123...456')
|
|
77
|
+
chkprompt(['あいうえお'], '1.2.3', 'あいうえお', '1.2.3')
|
|
78
|
+
})
|
|
79
|
+
it('文字尋 - キャンセル', () => {
|
|
80
|
+
const sys = { __v0: { 空: '' } }
|
|
81
|
+
chkprompt(['あいうえお', sys], null, 'あいうえお', '')
|
|
82
|
+
})
|
|
83
|
+
})
|
|
84
|
+
describe('二択', () => {
|
|
85
|
+
const chkconfirm = (args, rtn, msg, res) => {
|
|
86
|
+
const fakeConfirm = td.func('confirm')
|
|
87
|
+
td.when(fakeConfirm(msg)).thenReturn(rtn)
|
|
88
|
+
global.window = {}
|
|
89
|
+
global.window.confirm = fakeConfirm
|
|
90
|
+
global.confirm = fakeConfirm
|
|
91
|
+
assert.equal(PluginBrowser['二択'].fn.apply(this, args), res)
|
|
92
|
+
td.verify(fakeConfirm(td.matchers.anything()), { times: 1 })
|
|
93
|
+
td.reset()
|
|
94
|
+
}
|
|
95
|
+
it('二択', () => {
|
|
96
|
+
chkconfirm(['あいうえお'], true, 'あいうえお', true)
|
|
97
|
+
chkconfirm(['あいうえお'], false, 'あいうえお', false)
|
|
98
|
+
})
|
|
99
|
+
})
|
|
100
|
+
})
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const PluginBrowser = require('../../src/plugin_browser')
|
|
2
|
+
const { PluginUtHelper } = require('../../utils/plugin_ut_helper')
|
|
3
|
+
|
|
4
|
+
describe('plugin_browser_html', () => {
|
|
5
|
+
const cu = new PluginUtHelper(PluginBrowser)
|
|
6
|
+
|
|
7
|
+
it('HTML変換', () => {
|
|
8
|
+
cu.cmpfn('HTML変換', ['texT'], 'texT')
|
|
9
|
+
cu.cmpifn('HTML変換', ['<?!==?>'], '<?!==?>')
|
|
10
|
+
cu.cmpifn('HTML変換', ['2&3'], '2&3')
|
|
11
|
+
cu.cmpifn('HTML変換', ['<>&'], '&lt;&gt;&amp;')
|
|
12
|
+
})
|
|
13
|
+
})
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const PluginBrowser = require('../../src/plugin_browser')
|
|
2
|
+
const { PluginUtHelper } = require('../../utils/plugin_ut_helper')
|
|
3
|
+
|
|
4
|
+
describe('plugin_browser_system', () => {
|
|
5
|
+
const cu = new PluginUtHelper(PluginBrowser)
|
|
6
|
+
|
|
7
|
+
it('終わる', () => {
|
|
8
|
+
cu.cmpfnex('終', [], 'Error', '__終わる__')
|
|
9
|
+
})
|
|
10
|
+
})
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const assert = require('assert')
|
|
2
|
+
const NakoCompiler = require('../../src/nako3')
|
|
3
|
+
const PluginCSV = require('../../src/plugin_csv')
|
|
4
|
+
|
|
5
|
+
describe('plugin_csv_test', () => {
|
|
6
|
+
const nako = new NakoCompiler()
|
|
7
|
+
// nako.logger.addListener('trace', ({ browserConsole }) => { console.log(...browserConsole) })
|
|
8
|
+
nako.addPluginObject('PluginCSV', PluginCSV)
|
|
9
|
+
|
|
10
|
+
const cmp = (code, res) => {
|
|
11
|
+
nako.logger.debug('code=' + code)
|
|
12
|
+
assert.strictEqual(nako.run(code).log, res)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// --- test ---
|
|
16
|
+
it('CSV取得', () => {
|
|
17
|
+
cmp('a=「1,2,3\n4,5,6」のCSV取得。a[1][2]を表示', '6')
|
|
18
|
+
cmp('a=「"a",b,c\n""a,b,c\na,""b,c\na,b,c""\n"a,\nb",c,d\na,"b,\nc",d\na,b,"c,\nd"」のCSV取得。a[5][1]を表示', 'b,\nc')
|
|
19
|
+
cmp('a=「1,"a""a",2」のCSV取得。a[0][1]を表示', 'a"a')
|
|
20
|
+
cmp('a=「1,"2""2",3\n4,5,6」のCSV取得。a[0][1]を表示', '2"2')
|
|
21
|
+
cmp('a=「1,,3\n4,5,6」のCSV取得。a[0][2]を表示', '3')
|
|
22
|
+
cmp('a=「1,2,3,\n4,5,6」のCSV取得。a[1][0]を表示', '4') // #353
|
|
23
|
+
})
|
|
24
|
+
it('TSV取得', () => {
|
|
25
|
+
cmp('a=「1\t2\t3\n4\t5\t6」のTSV取得。a[1][2]を表示', '6')
|
|
26
|
+
cmp('a=「"a"\tb\tc\n""a\tb\tc\na\t""b\tc\na\tb\tc""\n"a\t\nb"\tc\td\na\t"b\t\nc"\td\na\tb\t"c\t\nd"」のTSV取得。a[5][1]を表示', 'b\t\nc')
|
|
27
|
+
cmp('a=「1\t"a""a"\t2」のTSV取得。a[0][1]を表示', 'a"a')
|
|
28
|
+
cmp('a=「1\t"2""2"\t3\n4\t5\t6」のTSV取得。a[0][1]を表示', '2"2')
|
|
29
|
+
cmp('a=「1\t\t3\n4\t5\t6」のTSV取得。a[0][2]を表示', '3')
|
|
30
|
+
})
|
|
31
|
+
it('表CSV変換', () => {
|
|
32
|
+
cmp('[[1,2,3],[4,5,6]]を表CSV変換して表示', '1,2,3\r\n4,5,6')
|
|
33
|
+
cmp('[[1,2,"3\r\n,"],[4,5,6]]を表CSV変換して表示', '1,2,"3\r\n,"\r\n4,5,6')
|
|
34
|
+
})
|
|
35
|
+
it('表TSV変換', () => {
|
|
36
|
+
cmp('[[1,2,3],[4,5,6]]を表TSV変換して表示', '1\t2\t3\r\n4\t5\t6')
|
|
37
|
+
cmp('[[1,2,"3\r\n\t"],[4,5,6]]を表TSV変換して表示', '1\t2\t"3\r\n\t"\r\n4\t5\t6')
|
|
38
|
+
})
|
|
39
|
+
})
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
const assert = require('assert')
|
|
2
|
+
const NakoCompiler = require('../../src/nako3')
|
|
3
|
+
const {NakoRuntimeError} = require('../../src/nako_errors')
|
|
4
|
+
const PluginDateTime = require('../../src/plugin_datetime')
|
|
5
|
+
|
|
6
|
+
describe('plugin_datetime_test', () => {
|
|
7
|
+
const nako = new NakoCompiler()
|
|
8
|
+
// nako.logger.addListener('trace', ({ browserConsole }) => { console.log(...browserConsole) })
|
|
9
|
+
nako.addPluginObject('PluginDateTime', PluginDateTime)
|
|
10
|
+
|
|
11
|
+
const cmp = (code, res) => {
|
|
12
|
+
nako.logger.debug('code=' + code)
|
|
13
|
+
assert.strictEqual(nako.run(code).log, res)
|
|
14
|
+
}
|
|
15
|
+
const cmd = (code) => {
|
|
16
|
+
nako.logger.debug('code=' + code)
|
|
17
|
+
nako.run(code)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// --- test ---
|
|
21
|
+
it('日時', () => {
|
|
22
|
+
cmp('「2017/03/06」の曜日。それを表示', '月')
|
|
23
|
+
cmp('「2017/03/06」の曜日番号取得。それを表示', '1')
|
|
24
|
+
cmp('「2017/03/06 00:00:00」をUNIX時間変換して表示', '1488726000')
|
|
25
|
+
cmp('「2017/03/06 00:00:01」をUNIX時間変換して表示', '1488726001')
|
|
26
|
+
cmp('「2017/03/06 00:00:00」をUNIXTIME変換して表示', '1488726000')
|
|
27
|
+
cmp('「2017/03/06 00:00:01」をUNIXTIME変換して表示', '1488726001')
|
|
28
|
+
cmp('1488726000を日時変換して表示', '2017/03/06 00:00:00')
|
|
29
|
+
cmp('1504191600を日時変換して表示', '2017/09/01 00:00:00')
|
|
30
|
+
})
|
|
31
|
+
it('日時差', () => {
|
|
32
|
+
cmp('「2017/03/06」から「2018/03/06」までの年数差。それを表示', '1')
|
|
33
|
+
cmp('「2017/03/06」と「2018/03/06」の年数差。それを表示', '1')
|
|
34
|
+
cmp('「2018/03/06」から「2017/03/06」までの年数差。それを表示', '-1')
|
|
35
|
+
cmp('「2018/03/06」と「2017/03/06」の年数差。それを表示', '-1')
|
|
36
|
+
cmp('「2017/03/06」から「2017/04/06」までの月数差。それを表示', '1')
|
|
37
|
+
cmp('「2017/03/06」と「2017/04/06」の月数差。それを表示', '1')
|
|
38
|
+
cmp('「2017/04/06」から「2017/03/06」までの月数差。それを表示', '-1')
|
|
39
|
+
cmp('「2017/04/06」と「2017/03/06」の月数差。それを表示', '-1')
|
|
40
|
+
cmp('「2017/03/06」から「2017/04/06」までの日数差。それを表示', '31')
|
|
41
|
+
cmp('「2017/03/06」と「2017/04/06」の日数差。それを表示', '31')
|
|
42
|
+
cmp('「2017/04/06」から「2017/03/06」までの日数差。それを表示', '-31')
|
|
43
|
+
cmp('「2017/04/06」と「2017/03/06」の日数差。それを表示', '-31')
|
|
44
|
+
cmp('「2017/03/06 00:00:00」から「2017/03/06 12:00:00」までの時間差。それを表示', '12')
|
|
45
|
+
cmp('「2017/03/06 00:00:00」と「2017/03/06 12:00:00」の時間差。それを表示', '12')
|
|
46
|
+
cmp('「00:00:00」から「12:00:00」までの時間差。それを表示', '12')
|
|
47
|
+
cmp('「00:00:00」と「12:00:00」の時間差。それを表示', '12')
|
|
48
|
+
cmp('「2017/03/06 12:00:00」から「2017/03/06 00:00:00」までの時間差。それを表示', '-12')
|
|
49
|
+
cmp('「2017/03/06 12:00:00」と「2017/03/06 00:00:00」の時間差。それを表示', '-12')
|
|
50
|
+
cmp('「12:00:00」から「00:00:00」までの時間差。それを表示', '-12')
|
|
51
|
+
cmp('「12:00:00」と「00:00:00」の時間差。それを表示', '-12')
|
|
52
|
+
cmp('「2017/03/06 00:00:00」から「2017/03/06 00:59:00」までの分差。それを表示', '59')
|
|
53
|
+
cmp('「2017/03/06 00:00:00」と「2017/03/06 00:59:00」の分差。それを表示', '59')
|
|
54
|
+
cmp('「00:00:00」から「00:59:00」までの分差。それを表示', '59')
|
|
55
|
+
cmp('「00:00:00」と「00:59:00」の分差。それを表示', '59')
|
|
56
|
+
cmp('「2017/03/06 00:59:00」から「2017/03/06 00:00:00」までの分差。それを表示', '-59')
|
|
57
|
+
cmp('「2017/03/06 00:59:00」と「2017/03/06 00:00:00」の分差。それを表示', '-59')
|
|
58
|
+
cmp('「00:59:00」から「00:00:00」までの分差。それを表示', '-59')
|
|
59
|
+
cmp('「00:59:00」と「00:00:00」の分差。それを表示', '-59')
|
|
60
|
+
cmp('「2017/03/06 00:00:00」から「2017/03/06 00:00:59」までの秒差。それを表示', '59')
|
|
61
|
+
cmp('「2017/03/06 00:00:00」と「2017/03/06 00:00:59」の秒差。それを表示', '59')
|
|
62
|
+
cmp('「00:00:00」から「00:00:59」までの秒差。それを表示', '59')
|
|
63
|
+
cmp('「00:00:00」と「00:00:59」の秒差。それを表示', '59')
|
|
64
|
+
cmp('「2017/03/06 00:00:59」から「2017/03/06 00:00:00」までの秒差。それを表示', '-59')
|
|
65
|
+
cmp('「2017/03/06 00:00:59」と「2017/03/06 00:00:00」の秒差。それを表示', '-59')
|
|
66
|
+
cmp('「00:00:59」から「00:00:00」までの秒差。それを表示', '-59')
|
|
67
|
+
cmp('「00:00:59」と「00:00:00」の秒差。それを表示', '-59')
|
|
68
|
+
cmp('「2020/07/17 00:00:00」と「2020/07/18 00:00:00」の「時間」による日時差を表示', '24')
|
|
69
|
+
})
|
|
70
|
+
it('日時加算', () => {
|
|
71
|
+
cmp('「2017/03/06 00:00:01」に「+01:02:03」を時間加算。それを表示', '2017/03/06 01:02:04')
|
|
72
|
+
cmp('「00:00:01」に「+01:02:03」を時間加算。それを表示', '01:02:04')
|
|
73
|
+
cmp('「2017/03/06 00:00:01」に「-01:02:03」を時間加算。それを表示', '2017/03/05 22:57:58')
|
|
74
|
+
cmp('「00:00:01」に「-01:02:03」を時間加算。それを表示', '22:57:58')
|
|
75
|
+
cmp('「2017/03/06 00:00:01」に「+1年」を日時加算。それを表示', '2018/03/06 00:00:01')
|
|
76
|
+
cmp('「2017/03/06」に「+1年」を日時加算。それを表示', '2018/03/06')
|
|
77
|
+
cmp('「2017/03/06 00:00:01」に「+1ヶ月」を日時加算。それを表示', '2017/04/06 00:00:01')
|
|
78
|
+
cmp('「2017/03/06」に「+1ヶ月」を日時加算。それを表示', '2017/04/06')
|
|
79
|
+
cmp('「2017/03/06 00:00:01」に「+1日」を日時加算。それを表示', '2017/03/07 00:00:01')
|
|
80
|
+
cmp('「2017/03/06」に「+1日」を日時加算。それを表示', '2017/03/07')
|
|
81
|
+
cmp('「2017/03/06 00:00:01」に「+1時間」を日時加算。それを表示', '2017/03/06 01:00:01')
|
|
82
|
+
cmp('「00:00:01」に「+1時間」を日時加算。それを表示', '01:00:01')
|
|
83
|
+
cmp('「2017/03/06 00:00:01」に「+2分」を日時加算。それを表示', '2017/03/06 00:02:01')
|
|
84
|
+
cmp('「00:00:01」に「+2分」を日時加算。それを表示', '00:02:01')
|
|
85
|
+
cmp('「2017/03/06 00:00:01」に「+3秒」を日時加算。それを表示', '2017/03/06 00:00:04')
|
|
86
|
+
cmp('「00:00:01」に「+3秒」を日時加算。それを表示', '00:00:04')
|
|
87
|
+
cmp('「2017/03/06 00:00:01」に「-1年」を日時加算。それを表示', '2016/03/06 00:00:01')
|
|
88
|
+
cmp('「2017/03/06」に「-1年」を日時加算。それを表示', '2016/03/06')
|
|
89
|
+
cmp('「2017/03/06 00:00:01」に「-1ヶ月」を日時加算。それを表示', '2017/02/06 00:00:01')
|
|
90
|
+
cmp('「2017/03/06」に「-1ヶ月」を日時加算。それを表示', '2017/02/06')
|
|
91
|
+
cmp('「2017/03/06 00:00:01」に「-1日」を日時加算。それを表示', '2017/03/05 00:00:01')
|
|
92
|
+
cmp('「2017/03/06」に「-1日」を日時加算。それを表示', '2017/03/05')
|
|
93
|
+
cmp('「2017/03/06 00:00:01」に「-1時間」を日時加算。それを表示', '2017/03/05 23:00:01')
|
|
94
|
+
cmp('「00:00:01」に「-1時間」を日時加算。それを表示', '23:00:01')
|
|
95
|
+
cmp('「2017/03/06 00:00:01」に「-2分」を日時加算。それを表示', '2017/03/05 23:58:01')
|
|
96
|
+
cmp('「00:00:01」に「-2分」を日時加算。それを表示', '23:58:01')
|
|
97
|
+
cmp('「2017/03/06 00:00:01」に「-3秒」を日時加算。それを表示', '2017/03/05 23:59:58')
|
|
98
|
+
cmp('「00:00:01」に「-3秒」を日時加算。それを表示', '23:59:58')
|
|
99
|
+
cmp('「2017/03/06 00:00:01」に「+0001/02/03」を日付加算。それを表示', '2018/05/09 00:00:01')
|
|
100
|
+
cmp('「2017/03/06」に「+0001/02/03」を日付加算。それを表示', '2018/05/09')
|
|
101
|
+
cmp('「2017/03/06 00:00:01」に「-0001/02/03」を日付加算。それを表示', '2016/01/03 00:00:01')
|
|
102
|
+
cmp('「2017/03/06」に「-0001/02/03」を日付加算。それを表示', '2016/01/03')
|
|
103
|
+
})
|
|
104
|
+
it('元号データ, 和暦変換', () => {
|
|
105
|
+
assert.throws(
|
|
106
|
+
() => cmd('「1868/10/22」を和暦変換。それを表示'),
|
|
107
|
+
NakoRuntimeError,
|
|
108
|
+
/『和暦変換』は明治以前の日付には対応していません。/
|
|
109
|
+
)
|
|
110
|
+
cmp('「1868/10/23」を和暦変換。それを表示', '明治元/10/23')
|
|
111
|
+
cmp('「1912/07/29」を和暦変換。それを表示', '明治45/07/29')
|
|
112
|
+
cmp('「1912/07/30」を和暦変換。それを表示', '大正元/07/30')
|
|
113
|
+
cmp('「1926/12/24」を和暦変換。それを表示', '大正15/12/24')
|
|
114
|
+
cmp('「1926/12/25」を和暦変換。それを表示', '昭和元/12/25')
|
|
115
|
+
cmp('「1989/01/07」を和暦変換。それを表示', '昭和64/01/07')
|
|
116
|
+
cmp('「1989/01/08」を和暦変換。それを表示', '平成元/01/08')
|
|
117
|
+
cmp('「2019/04/30」を和暦変換。それを表示', '平成31/04/30')
|
|
118
|
+
cmp('「2019/05/01」を和暦変換。それを表示', '令和元/05/01')
|
|
119
|
+
})
|
|
120
|
+
})
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const assert = require('assert')
|
|
2
|
+
const NakoCompiler = require('../../src/nako3')
|
|
3
|
+
const PluginKansuji = require('../../src/plugin_kansuji.js')
|
|
4
|
+
|
|
5
|
+
describe('plugin_kansuji_test', () => {
|
|
6
|
+
const nako = new NakoCompiler()
|
|
7
|
+
// nako.logger.addListener('trace', ({ browserConsole }) => { console.log(...browserConsole) })
|
|
8
|
+
nako.addPluginFile('PluginKansuji', 'plugin_kansuji.js', PluginKansuji)
|
|
9
|
+
const cmp = (code, res) => {
|
|
10
|
+
nako.logger.debug('code=' + code)
|
|
11
|
+
|
|
12
|
+
assert.strictEqual(nako.run(code).log, res)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// --- test ---
|
|
16
|
+
it('漢数字', () => {
|
|
17
|
+
cmp('「三・一四」の算用数字を表示。', '3.14')
|
|
18
|
+
cmp('3.14の漢数字を表示。', '三・一四')
|
|
19
|
+
cmp('1234567890の漢数字を表示。', '十二億三千四百五十六万七千八百九十')
|
|
20
|
+
cmp('「1234567890」の漢数字を表示。', '十二億三千四百五十六万七千八百九十')
|
|
21
|
+
cmp('「二億九千九百七十九万二千四百五十八」の算用数字を表示。', '299792458')
|
|
22
|
+
cmp('「1e+10」の漢数字の算用数字を表示。', '10000000000')
|
|
23
|
+
cmp('「1e10」の漢数字の算用数字を表示。', '10000000000')
|
|
24
|
+
cmp('「1e-10」の漢数字の算用数字を表示。', '1e-10')
|
|
25
|
+
cmp('「1.1」の漢数字の算用数字を表示。', '1.1')
|
|
26
|
+
cmp('「1.1e+1」の漢数字の算用数字を表示。', '11')
|
|
27
|
+
cmp('「1.234e+2」の漢数字の算用数字を表示。', '123.4')
|
|
28
|
+
cmp('「1.234e2」の漢数字の算用数字を表示。', '123.4')
|
|
29
|
+
cmp('「1.234e23」の漢数字の算用数字を表示。', '123400000000000000000000')
|
|
30
|
+
cmp('「1.234e-23」の漢数字の算用数字を表示。', '1.234e-23')
|
|
31
|
+
cmp('「901.1234e-2」の漢数字の算用数字を表示。', '9.011234')
|
|
32
|
+
cmp('「0」の漢数字の算用数字を表示。', '0')
|
|
33
|
+
cmp('「1」の漢数字の算用数字を表示。', '1')
|
|
34
|
+
cmp('「10」の漢数字の算用数字を表示。', '10')
|
|
35
|
+
cmp('「11」の漢数字の算用数字を表示。', '11')
|
|
36
|
+
cmp('「12」の漢数字の算用数字を表示。', '12')
|
|
37
|
+
cmp('「20」の漢数字の算用数字を表示。', '20')
|
|
38
|
+
cmp('「102」の漢数字の算用数字を表示。', '102')
|
|
39
|
+
cmp('「200」の漢数字の算用数字を表示。', '200')
|
|
40
|
+
cmp('「1002」の漢数字の算用数字を表示。', '1002')
|
|
41
|
+
cmp('「1020」の漢数字の算用数字を表示。', '1020')
|
|
42
|
+
cmp('「2000」の漢数字の算用数字を表示。', '2000')
|
|
43
|
+
cmp('「10002」の漢数字の算用数字を表示。', '10002')
|
|
44
|
+
cmp('「20000」の漢数字の算用数字を表示。', '20000')
|
|
45
|
+
cmp('「10000000」の漢数字の算用数字を表示。', '10000000')
|
|
46
|
+
cmp('「100000000」の漢数字の算用数字を表示。', '100000000')
|
|
47
|
+
cmp('「28000103206018」の漢数字の算用数字を表示。', '28000103206018')
|
|
48
|
+
cmp('「161803398874989484820458683436563811772030917980576286213544862270526046」の漢数字の算用数字を表示。', '161803398874989484820458683436563811772030917980576286213544862270526046')
|
|
49
|
+
})
|
|
50
|
+
//
|
|
51
|
+
it('漢数字の0とマイナス #874', () => {
|
|
52
|
+
cmp('0の漢数字を表示。', '零')
|
|
53
|
+
cmp('「0」の漢数字を表示。', '零')
|
|
54
|
+
cmp('「零」の算用数字を表示。', '0')
|
|
55
|
+
cmp('-1の漢数字を表示。', '-一')
|
|
56
|
+
cmp('"+1"の漢数字を表示。', '+一')
|
|
57
|
+
cmp('「-1」の漢数字を表示。', '-一')
|
|
58
|
+
})
|
|
59
|
+
})
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const assert = require('assert')
|
|
2
|
+
const NakoCompiler = require('../../src/nako3')
|
|
3
|
+
|
|
4
|
+
describe('plugin_promise_test', () => {
|
|
5
|
+
const nako = new NakoCompiler()
|
|
6
|
+
const cmp = async (code, res, time) => {
|
|
7
|
+
nako.logger.debug('code=' + code)
|
|
8
|
+
const r = nako.run(code)
|
|
9
|
+
setTimeout(() => {
|
|
10
|
+
assert.strictEqual(r.log, res)
|
|
11
|
+
}, time)
|
|
12
|
+
}
|
|
13
|
+
// --- test ---
|
|
14
|
+
it('Promise', async () => {
|
|
15
|
+
cmp('Fは動いた時には(成功,失敗)\n成功(9)\nここまで\nFの成功した時には\n対象を表示\nここまで\nその失敗した時には\n"NG"を表示\nここまで', '9', 50)
|
|
16
|
+
cmp('Fは動いた時には(成功,失敗)\n失敗(5)\nここまで\nFの成功した時には\n"NG"を表示\nここまで\nその失敗した時には\n対象を表示\nここまで', '5', 50)
|
|
17
|
+
})
|
|
18
|
+
})
|