Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
d27a7be9
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
d27a7be9
编写于
2月 26, 2022
作者:
O
openharmony_ci
提交者:
Gitee
2月 26, 2022
浏览文件
操作
浏览文件
下载
差异文件
!1977 Add testcase for js intl
Merge pull request !1977 from 黄河/master
上级
fe048817
294b2cae
变更
18
显示空白变更内容
内联
并排
Showing
18 changed file
with
812 addition
and
0 deletion
+812
-0
compileruntime/BUILD.gn
compileruntime/BUILD.gn
+1
-0
compileruntime/ark_intl_standard/intljs/BUILD.gn
compileruntime/ark_intl_standard/intljs/BUILD.gn
+31
-0
compileruntime/ark_intl_standard/intljs/Test.json
compileruntime/ark_intl_standard/intljs/Test.json
+30
-0
compileruntime/ark_intl_standard/intljs/signature/openharmony_sx.p7b
...ime/ark_intl_standard/intljs/signature/openharmony_sx.p7b
+0
-0
compileruntime/ark_intl_standard/intljs/src/main/config.json
compileruntime/ark_intl_standard/intljs/src/main/config.json
+60
-0
compileruntime/ark_intl_standard/intljs/src/main/js/default/app.js
...ntime/ark_intl_standard/intljs/src/main/js/default/app.js
+22
-0
compileruntime/ark_intl_standard/intljs/src/main/js/default/i18n/en-US.json
..._intl_standard/intljs/src/main/js/default/i18n/en-US.json
+8
-0
compileruntime/ark_intl_standard/intljs/src/main/js/default/i18n/zh-CN.json
..._intl_standard/intljs/src/main/js/default/i18n/zh-CN.json
+8
-0
compileruntime/ark_intl_standard/intljs/src/main/js/default/pages/index/index.css
...standard/intljs/src/main/js/default/pages/index/index.css
+9
-0
compileruntime/ark_intl_standard/intljs/src/main/js/default/pages/index/index.hml
...standard/intljs/src/main/js/default/pages/index/index.hml
+5
-0
compileruntime/ark_intl_standard/intljs/src/main/js/default/pages/index/index.js
..._standard/intljs/src/main/js/default/pages/index/index.js
+43
-0
compileruntime/ark_intl_standard/intljs/src/main/js/default/test/List.test.js
...ntl_standard/intljs/src/main/js/default/test/List.test.js
+18
-0
compileruntime/ark_intl_standard/intljs/src/main/js/default/test/intlCollator_test.js
...dard/intljs/src/main/js/default/test/intlCollator_test.js
+74
-0
compileruntime/ark_intl_standard/intljs/src/main/js/default/test/intlDateTimeFormat_test.js
...ntljs/src/main/js/default/test/intlDateTimeFormat_test.js
+354
-0
compileruntime/ark_intl_standard/intljs/src/main/js/default/test/intlLocale_test.js
...andard/intljs/src/main/js/default/test/intlLocale_test.js
+31
-0
compileruntime/ark_intl_standard/intljs/src/main/js/default/test/numberFormat_test.js
...dard/intljs/src/main/js/default/test/numberFormat_test.js
+106
-0
compileruntime/ark_intl_standard/intljs/src/main/resources/base/element/string.json
...andard/intljs/src/main/resources/base/element/string.json
+12
-0
compileruntime/ark_intl_standard/intljs/src/main/resources/base/media/icon.png
...tl_standard/intljs/src/main/resources/base/media/icon.png
+0
-0
未找到文件。
compileruntime/BUILD.gn
浏览文件 @
d27a7be9
...
@@ -16,6 +16,7 @@ group("compileruntime") {
...
@@ -16,6 +16,7 @@ group("compileruntime") {
testonly = true
testonly = true
if (is_standard_system) {
if (is_standard_system) {
deps = [
deps = [
"ark_intl_standard/intljs:intljs_test",
"convertxml_lib_standard:convertxml_js_test",
"convertxml_lib_standard:convertxml_js_test",
"process_lib_standard:process_js_test",
"process_lib_standard:process_js_test",
"uri_lib_standard:uri_js_test",
"uri_lib_standard:uri_js_test",
...
...
compileruntime/ark_intl_standard/intljs/BUILD.gn
0 → 100644
浏览文件 @
d27a7be9
# Copyright (C) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("intljs_test") {
hap_profile = "./src/main/config.json"
deps = [
":intljs_assets",
":intljs_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsIntlJsApiTest"
}
ohos_js_assets("intljs_assets") {
source_dir = "./src/main/js/default"
}
ohos_resources("intljs_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
compileruntime/ark_intl_standard/intljs/Test.json
0 → 100644
浏览文件 @
d27a7be9
{
"description"
:
"Configuration for intljs Tests"
,
"driver"
:
{
"type"
:
"JSUnitTest"
,
"test-timeout"
:
"300000"
,
"package"
:
"ohos.intl.test"
,
"shell-timeout"
:
"60000"
},
"kits"
:
[
{
"test-file-name"
:
[
"ActsIntlJsApiTest.hap"
],
"type"
:
"AppInstallKit"
,
"cleanup-apps"
:
true
},
{
"type"
:
"PushKit"
,
"push"
:
[
"resource/global/white_languages.xml->/system/usr/ohos_locale_config/white_languages.xml"
]
},
{
"type"
:
"ShellKit"
,
"run-command"
:
[
"chmod 644 /system/usr/ohos_locale_config/white_languages.xml"
]
}
]
}
compileruntime/ark_intl_standard/intljs/signature/openharmony_sx.p7b
0 → 100644
浏览文件 @
d27a7be9
文件已添加
compileruntime/ark_intl_standard/intljs/src/main/config.json
0 → 100644
浏览文件 @
d27a7be9
{
"app"
:
{
"bundleName"
:
"ohos.intl.test"
,
"vendor"
:
"example"
,
"version"
:
{
"code"
:
1
,
"name"
:
"1.0"
},
"apiVersion"
:
{
"compatible"
:
4
,
"target"
:
5
}
},
"deviceConfig"
:
{},
"module"
:
{
"package"
:
"ohos.intl.test"
,
"name"
:
".MyApplication"
,
"deviceType"
:
[
"phone"
],
"distro"
:
{
"deliveryWithInstall"
:
true
,
"moduleName"
:
"entry"
,
"moduleType"
:
"entry"
},
"abilities"
:
[
{
"visible"
:
true
,
"skills"
:
[
{
"entities"
:
[
"entity.system.home"
],
"actions"
:
[
"action.system.home"
]
}
],
"name"
:
"ohos.intl.test.MainAbility"
,
"icon"
:
"$media:icon"
,
"description"
:
"$string:mainability_description"
,
"label"
:
"MyApplication"
,
"type"
:
"page"
,
"launchType"
:
"standard"
}
],
"js"
:
[
{
"pages"
:
[
"pages/index/index"
],
"name"
:
"default"
,
"window"
:
{
"designWidth"
:
720
,
"autoDesignWidth"
:
false
}
}
]
}
}
compileruntime/ark_intl_standard/intljs/src/main/js/default/app.js
0 → 100644
浏览文件 @
d27a7be9
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export
default
{
onCreate
()
{
console
.
info
(
'
TestApplication onCreate
'
);
},
onDestroy
()
{
console
.
info
(
'
TestApplication onDestroy
'
);
}
};
compileruntime/ark_intl_standard/intljs/src/main/js/default/i18n/en-US.json
0 → 100644
浏览文件 @
d27a7be9
{
"strings"
:
{
"hello"
:
"Hello"
,
"world"
:
"World"
},
"Files"
:
{
}
}
\ No newline at end of file
compileruntime/ark_intl_standard/intljs/src/main/js/default/i18n/zh-CN.json
0 → 100644
浏览文件 @
d27a7be9
{
"strings"
:
{
"hello"
:
"您好"
,
"world"
:
"世界"
},
"Files"
:
{
}
}
\ No newline at end of file
compileruntime/ark_intl_standard/intljs/src/main/js/default/pages/index/index.css
0 → 100644
浏览文件 @
d27a7be9
.container
{
flex-direction
:
column
;
justify-content
:
center
;
align-items
:
center
;
}
.title
{
font-size
:
100px
;
}
compileruntime/ark_intl_standard/intljs/src/main/js/default/pages/index/index.hml
0 → 100644
浏览文件 @
d27a7be9
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
compileruntime/ark_intl_standard/intljs/src/main/js/default/pages/index/index.js
0 → 100644
浏览文件 @
d27a7be9
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
{
Core
,
ExpectExtend
}
from
'
deccjsunit/index
'
export
default
{
data
:
{
title
:
""
},
onInit
()
{
this
.
title
=
this
.
$t
(
'
strings.world
'
);
},
onShow
()
{
console
.
info
(
'
onShow finish
'
)
const
core
=
Core
.
getInstance
()
const
expectExtend
=
new
ExpectExtend
({
'
id
'
:
'
extend
'
})
core
.
addService
(
'
expect
'
,
expectExtend
)
core
.
init
()
const
configService
=
core
.
getDefaultService
(
'
config
'
)
configService
.
setConfig
(
this
)
require
(
'
../../test/List.test
'
)
core
.
execute
()
},
onReady
()
{
},
}
\ No newline at end of file
compileruntime/ark_intl_standard/intljs/src/main/js/default/test/List.test.js
0 → 100644
浏览文件 @
d27a7be9
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require
(
'
./intlLocale_test.js
'
)
require
(
'
./intlCollator_test.js
'
)
require
(
'
./intlDateTimeFormat_test.js
'
)
require
(
'
./numberFormat_test.js
'
)
compileruntime/ark_intl_standard/intljs/src/main/js/default/test/intlCollator_test.js
0 → 100644
浏览文件 @
d27a7be9
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
Intl
from
'
@ohos.intl
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
intlDateTimeFormatTest
'
,
function
()
{
console
.
log
(
"
*******test start*******
"
)
/* *
* @tc.number ARK_INTL_JS_DATETIME_004
* @tc.name the locale in de
* @tc.desc check the sort in de
*/
it
(
'
collator_info_test_004
'
,
0
,
function
()
{
var
collator1
=
new
Intl
.
Collator
(
'
de
'
).
compare
(
'
ä
'
,
'
z
'
);
console
.
log
(
collator1
);
expect
(
collator1
).
assertEqual
(
-
1
);
var
collator2
=
new
Intl
.
Collator
(
'
sv
'
).
compare
(
'
ä
'
,
'
z
'
);
console
.
log
(
collator2
);
expect
(
collator2
).
assertEqual
(
1
);
})
/* *
* @tc.number ARK_INTL_JS_DATETIME_005
* @tc.name the locale in de and sv
* @tc.desc check the sort in de and sv
*/
it
(
'
collator_info_test_005
'
,
0
,
function
()
{
var
collator1
=
new
Intl
.
Collator
(
'
de
'
,{
sensitivity
:
'
base
'
}).
compare
(
'
ä
'
,
'
a
'
);
console
.
log
(
collator1
);
var
collator2
=
new
Intl
.
Collator
(
'
sv
'
,{
sensitivity
:
'
base
'
}).
compare
(
'
ä
'
,
'
a
'
);
console
.
log
(
collator2
);
expect
(
collator1
).
assertEqual
(
0
);
expect
(
collator2
).
assertEqual
(
1
);
})
/* *
* @tc.number ARK_INTL_JS_DATETIME_006
* @tc.name the locale in zh-Hans
* @tc.desc check the resolvedOptions of collator
*/
it
(
'
collator_info_test_006
'
,
0
,
function
()
{
var
collator
=
new
Intl
.
Collator
(
"
zh-Hans
"
,{
sensitivity
:
'
base
'
,
caseFirst
:
'
upper
'
,
ignorePunctuation
:
'
true
'
});
var
options
=
collator
.
resolvedOptions
();
console
.
log
(
"
collator_info_test_006:
"
,
options
.
caseFirst
);
expect
(
options
.
caseFirst
).
assertEqual
(
'
upper
'
);
})
/* *
* @tc.number ARK_INTL_JS_DATETIME_007
* @tc.name the locale in zh-Hans
* @tc.desc check the resolvedOptions of collator
*/
it
(
'
collator_info_test_007
'
,
0
,
function
()
{
var
collator
=
new
Intl
.
Collator
(
"
zh-Hans
"
,{
sensitivity
:
'
base
'
,
caseFirst
:
'
upper
'
,
ignorePunctuation
:
'
true
'
});
var
options
=
collator
.
resolvedOptions
();
console
.
log
(
"
collator_info_test_007:
"
,
options
.
sensitivity
);
expect
(
options
.
sensitivity
).
assertEqual
(
'
base
'
);
})
})
compileruntime/ark_intl_standard/intljs/src/main/js/default/test/intlDateTimeFormat_test.js
0 → 100644
浏览文件 @
d27a7be9
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
Intl
from
'
@ohos.intl
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
intlDateTimeFormatTest_1
'
,
function
()
{
console
.
log
(
'
******test start******
'
)
/* *
* @tc.number ARK_INTL_JS_DATETIME_001
* @tc.name format the datetime with en-GB locale
* @tc.desc check the datetime is not null
*/
it
(
'
dateTimeFormat_test_001
'
,
0
,
function
()
{
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
en-GB
'
);
expect
(
datefmt
!==
null
).
assertTrue
();
})
/* *
* @tc.number ARK_INTL_JS_DATETIME_002
* @tc.name format the datetime with en-GB locale
* @tc.desc check the datetime is not null
*/
it
(
'
dateTimeFormat_test_002
'
,
0
,
function
()
{
let
datefmt
=
new
Intl
.
DateTimeFormat
();
expect
(
datefmt
!==
null
).
assertTrue
();
})
/* *
* @tc.number ARK_INTL_JS_DATETIME_003
* @tc.name format the date with zh locale
* @tc.desc check the date
*/
it
(
'
dateTimeFormat_test_003
'
,
0
,
function
()
{
let
date
=
new
Date
(
2021
,
11
,
17
,
3
,
24
,
0
);
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh
'
);
console
.
log
(
'
dateTimeFormat_test_003
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertEqual
(
'
2021/12/17
'
);
})
})
describe
(
'
intlDateTimeFormatTest_2
'
,
function
()
{
console
.
log
(
'
******test start******
'
)
/* *
* @tc.number ARK_INTL_JS_DATETIME_005
* @tc.name format the date with da locale
* @tc.desc check the date
*/
it
(
'
dateTimeFormat_test_005
'
,
0
,
function
()
{
let
date
=
new
Date
(
2021
,
11
,
17
,
3
,
24
,
0
);
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
da
'
);
console
.
log
(
'
dateTimeFormat_test_005
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertEqual
(
'
17.12.2021
'
);
})
/* *
* @tc.number ARK_INTL_JS_DATETIME_006
* @tc.name format the date with en-GB locale
* @tc.desc check the date
*/
it
(
'
dateTimeFormat_test_006
'
,
0
,
function
()
{
let
date
=
new
Date
(
2021
,
11
,
17
,
3
,
24
,
0
);
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
en-GB
'
);
console
.
log
(
'
dateTimeFormat_test_006
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertEqual
(
'
17/12/2021
'
);
})
})
describe
(
'
intlDateTimeFormatTest_3
'
,
function
()
{
console
.
log
(
'
******test start******
'
)
/* *
* @tc.number ARK_INTL_JS_DATETIME_007
* @tc.name format the date with aa locale
* @tc.desc check the date
*/
it
(
'
dateTimeFormat_test_007
'
,
0
,
function
()
{
let
date
=
new
Date
(
2021
,
11
,
17
,
3
,
24
,
0
);
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
aa
'
);
let
value
=
datefmt
.
format
(
date
);
console
.
log
(
'
dateTimeFormat_test_007
'
+
value
);
expect
(
value
).
assertInstanceOf
(
'
String
'
);
})
/* *
* @tc.number ARK_INTL_JS_DATETIME_008
* @tc.name format the hour with ban and zh locale
* @tc.desc check the hour with ban and zh locale
*/
it
(
'
dateTimeFormat_test_008
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
option
=
{
dateStyle
:
'
full
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
([
'
ban
'
,
'
zh
'
],
option
);
console
.
log
(
'
dateTimeFormat_test_008
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertEqual
(
'
2020年12月20日星期日
'
);
})
/* *
* @tc.number ARK_INTL_JS_DATETIME_009
* @tc.name format the hour with en and zh locale
* @tc.desc check the hour with en and zh locale
*/
it
(
'
dateTimeFormat_test_009
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
option
=
{
dateStyle
:
'
full
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
([
'
en
'
,
'
zh
'
],
option
);
console
.
log
(
'
dateTimeFormat_test_009
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertEqual
(
'
Sunday, December 20, 2020
'
);
})
})
describe
(
'
intlDateTimeFormatTest_4
'
,
function
()
{
console
.
log
(
'
******test start******
'
)
/* *
* @tc.number ARK_INTL_JS_DATETIME_010
* @tc.name format the hour with en and ban locale
* @tc.desc check the hour with en and ban locale
*/
it
(
'
dateTimeFormat_test_010
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
option
=
{
dateStyle
:
'
full
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
([
'
en
'
,
'
ban
'
],
option
);
console
.
log
(
'
dateTimeFormat_test_010
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertEqual
(
'
Sunday, December 20, 2020
'
);
})
/* *
* @tc.number ARK_INTL_JS_DATETIME_013
* @tc.name format the date dateStyle with long style
* @tc.desc check the dateStyle with long style
*/
it
(
'
dateTimeFormat_test_013
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
option
=
{
dateStyle
:
'
long
'
,
timeStyle
:
'
long
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-CN
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_013
'
+
datefmt
.
resolvedOptions
().
dateStyle
);
expect
(
datefmt
.
resolvedOptions
().
dateStyle
).
assertEqual
(
'
long
'
);
})
/* *
* @tc.number ARK_INTL_JS_DATETIME_014
* @tc.name format the date dateStyle with medium style
* @tc.desc check the dateStyle with medium style
*/
it
(
'
dateTimeFormat_test_014
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
option
=
{
dateStyle
:
'
medium
'
,
timeStyle
:
'
medium
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-CN
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_014
'
+
datefmt
.
resolvedOptions
().
dateStyle
);
expect
(
datefmt
.
resolvedOptions
().
dateStyle
).
assertEqual
(
'
medium
'
);
expect
(
datefmt
.
format
(
date
)).
assertEqual
(
'
2020年12月20日 下午2:23:16
'
);
})
})
describe
(
'
intlDateTimeFormatTest_5
'
,
function
()
{
console
.
log
(
'
******test start******
'
)
/* *
* @tc.number ARK_INTL_JS_DATETIME_017
* @tc.name format the date with daterange when the start and end date is equal
* @tc.desc check the daterange when the start and end date is equal
*/
it
(
'
dateTimeFormat_test_017
'
,
0
,
function
()
{
let
startdate
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
enddate
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
en-GB
'
);
console
.
log
(
'
dateTimeFormat_test_017
'
+
datefmt
.
formatRange
(
startdate
,
enddate
));
expect
(
datefmt
.
formatRange
(
startdate
,
enddate
)).
assertEqual
(
'
20/12/2020
'
);
})
/* *
* @tc.number ARK_INTL_JS_DATETIME_016
* @tc.name format the date with daterange
* @tc.desc check the daterange
*/
it
(
'
dateTimeFormat_test_016
'
,
0
,
function
()
{
let
startdate
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
enddate
=
new
Date
(
2020
,
11
,
21
,
14
,
23
,
16
);
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
en-GB
'
);
console
.
log
(
'
dateTimeFormat_test_016
'
+
datefmt
.
formatRange
(
startdate
,
enddate
));
expect
(
datefmt
.
formatRange
(
startdate
,
enddate
)).
assertEqual
(
'
20/12/2020 – 21/12/2020
'
);
})
/* *
* @tc.number ARK_INTL_JS_DATETIME_015
* @tc.name format the date dateStyle with short style
* @tc.desc check the dateStyle with short style
*/
it
(
'
dateTimeFormat_test_015
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
option
=
{
dateStyle
:
'
short
'
,
timeStyle
:
'
short
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-CN
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_015
'
+
datefmt
.
resolvedOptions
().
dateStyle
);
expect
(
datefmt
.
resolvedOptions
().
dateStyle
).
assertEqual
(
'
short
'
);
})
})
describe
(
'
intlDateTimeFormatTest_6
'
,
function
()
{
console
.
log
(
'
******test start******
'
)
/* *
* @tc.number ARK_INTL_JS_DATETIME_018
* @tc.name format the year、month、day、weekday
* @tc.desc check the year、month、day、weekday
*/
it
(
'
dateTimeFormat_test_018
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
option
=
{
year
:
'
numeric
'
,
month
:
'
long
'
,
day
:
'
numeric
'
,
weekday
:
'
long
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
ja
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_018
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertEqual
(
'
2020年12月20日日曜日
'
);
})
/* *
* @tc.number ARK_INTL_JS_DATETIME_019
* @tc.name format the timerange with year、month、day、weekday
* @tc.desc check the timerange with year、month、day、weekday
*/
it
(
'
dateTimeFormat_test_019
'
,
0
,
function
()
{
let
startdate
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
enddate
=
new
Date
(
2021
,
4
,
5
,
10
,
5
,
3
);
let
option
=
{
year
:
'
numeric
'
,
month
:
'
long
'
,
day
:
'
numeric
'
,
weekday
:
'
long
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
en
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_019
'
+
datefmt
.
formatRange
(
startdate
,
enddate
));
expect
(
datefmt
.
formatRange
(
startdate
,
enddate
)).
assertEqual
(
'
Sunday, December 20, 2020 – Wednesday, May 5, 2021
'
);
})
/* *
* @tc.number ARK_INTL_JS_DATETIME_020
* @tc.name format the hour&minute&second
* @tc.desc check the hour&minute&second
*/
it
(
'
dateTimeFormat_test_020
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
option
=
{
year
:
'
numeric
'
,
month
:
'
long
'
,
day
:
'
numeric
'
,
hour
:
'
numeric
'
,
minute
:
'
2-digit
'
,
second
:
'
numeric
'
,
weekday
:
'
long
'
,
era
:
'
short
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-CN-u-hc-h12
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_020
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertEqual
(
'
公元2020年12月20日星期日 下午2:23:16
'
);
})
})
describe
(
'
intlDateTimeFormatTest_7
'
,
function
()
{
console
.
log
(
'
******test start******
'
)
/* *
* @tc.number ARK_INTL_JS_DATETIME_021
* @tc.name format the timeZone
* @tc.desc check the timeZone
*/
it
(
'
dateTimeFormat_test_021
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
3
,
14
,
15
,
5
,
3
);
let
option
=
{
timeZone
:
'
America/Los_Angeles
'
,
timeZoneName
:
'
long
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-CN-u-hc-h12
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_021
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
).
indexOf
(
'
北美太平洋夏令时间
'
)
!==
-
1
).
assertTrue
();
})
/* *
* @tc.number ARK_INTL_JS_DATETIME_022
* @tc.name format the America/Los_Angeles timeZone
* @tc.desc check the America/Los_Angeles timeZone
*/
it
(
'
dateTimeFormat_test_022
'
,
0
,
function
()
{
let
option
=
{
timeZone
:
'
America/Los_Angeles
'
,
timeZoneName
:
'
long
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-CN-u-hc-h12
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_022
'
+
datefmt
.
resolvedOptions
().
timeZone
);
expect
(
datefmt
.
resolvedOptions
().
timeZone
).
assertEqual
(
'
America/Los_Angeles
'
);
})
/* *
* @tc.number ARK_INTL_JS_DATETIME_023
* @tc.name format the America/Los_Angeles timeZoneName
* @tc.desc check the America/Los_Angeles timeZoneName
*/
it
(
'
dateTimeFormat_test_023
'
,
0
,
function
()
{
let
option
=
{
timeZone
:
'
America/Los_Angeles
'
,
timeZoneName
:
'
long
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-CN-u-hc-h12
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_023
'
+
datefmt
.
resolvedOptions
().
timeZoneName
);
expect
(
datefmt
.
resolvedOptions
().
timeZoneName
).
assertEqual
(
'
long
'
);
})
/* *
* @tc.number ARK_INTL_JS_DATETIME_024
* @tc.name format the year
* @tc.desc check the year
*/
it
(
'
dateTimeFormat_test_024
'
,
0
,
function
()
{
let
option
=
{
year
:
'
numeric
'
,
month
:
'
long
'
,
day
:
'
numeric
'
,
hour
:
'
numeric
'
,
minute
:
'
2-digit
'
,
second
:
'
numeric
'
,
weekday
:
'
long
'
,
era
:
'
short
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-CN-u-hc-h12
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_024
'
+
datefmt
.
resolvedOptions
().
year
);
expect
(
datefmt
.
resolvedOptions
().
year
).
assertEqual
(
'
numeric
'
);
})
})
describe
(
'
intlDateTimeFormatTest_7
'
,
function
()
{
console
.
log
(
'
******test start******
'
)
/* *
* @tc.number ARK_INTL_JS_DATETIME_025
* @tc.name format the weekday
* @tc.desc check the weekday
*/
it
(
'
dateTimeFormat_test_025
'
,
0
,
function
()
{
let
option
=
{
year
:
'
numeric
'
,
month
:
'
long
'
,
day
:
'
numeric
'
,
hour
:
'
numeric
'
,
minute
:
'
2-digit
'
,
second
:
'
numeric
'
,
weekday
:
'
long
'
,
era
:
'
short
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-CN-u-hc-h12
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_025
'
+
datefmt
.
resolvedOptions
().
weekday
);
expect
(
datefmt
.
resolvedOptions
().
weekday
).
assertEqual
(
'
long
'
);
})
/* *
* @tc.number ARK_INTL_JS_DATETIME_026
* @tc.name format the hour in zh-CN-u-hc-h12
* @tc.desc check the hour in zh-CN-u-hc-h12
*/
it
(
'
dateTimeFormat_test_026
'
,
0
,
function
()
{
let
option
=
{
year
:
'
numeric
'
,
month
:
'
long
'
,
day
:
'
numeric
'
,
hour
:
'
numeric
'
,
minute
:
'
2-digit
'
,
second
:
'
numeric
'
,
weekday
:
'
long
'
,
era
:
'
short
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
zh-CN-u-hc-h12
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_026
'
+
datefmt
.
resolvedOptions
().
hour
);
expect
(
datefmt
.
resolvedOptions
().
hour
).
assertEqual
(
'
numeric
'
);
})
/* *
* @tc.number ARK_INTL_JS_DATETIME_027
* @tc.name format the hour in fr-Latn-FR-u-nu-mong
* @tc.desc check the hour in fr-Latn-FR-u-nu-mong
*/
it
(
'
dateTimeFormat_test_027
'
,
0
,
function
()
{
let
date
=
new
Date
(
2020
,
11
,
20
,
14
,
23
,
16
);
let
option
=
{
dateStyle
:
'
full
'
};
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
fr-Latn-FR-u-nu-mong
'
,
option
);
console
.
log
(
'
dateTimeFormat_test_027
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertEqual
(
'
dimanche ᠒᠐ décembre ᠒᠐᠒᠐
'
);
})
})
\ No newline at end of file
compileruntime/ark_intl_standard/intljs/src/main/js/default/test/intlLocale_test.js
0 → 100644
浏览文件 @
d27a7be9
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
Intl
from
'
@ohos.intl
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
intlDateTimeFormatTest
'
,
function
()
{
console
.
log
(
'
******* start IntlLocale_Test ******
'
)
/* *
* @tc.number ARK_INTL_JS_DATETIME_001
* @tc.name the locale in en-Latn-GB
* @tc.desc check the locale in en-Latn-GB
*/
it
(
'
locale_test_001
'
,
0
,
function
()
{
let
locale
=
new
Intl
.
Locale
(
'
en-Latn-GB
'
);
console
.
log
(
'
locale_test_001
'
+
locale
.
language
);
expect
(
locale
.
language
).
assertEqual
(
'
en
'
);
})
})
\ No newline at end of file
compileruntime/ark_intl_standard/intljs/src/main/js/default/test/numberFormat_test.js
0 → 100644
浏览文件 @
d27a7be9
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
Intl
from
'
@ohos.intl
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
intlDateTimeFormatTest
'
,
function
()
{
console
.
log
(
'
******test start********
'
);
/* *
* @tc.number ARK_INTL_JS_DATETIME_001
* @tc.name format the number in en-GB and zh
* @tc.desc check the number in en-GB and zh
*/
it
(
'
numberFormat_info_test_001
'
,
0
,
function
()
{
var
numfmt
=
new
Intl
.
NumberFormat
([
"
en-GB
"
,
"
zh
"
],
{
style
:
'
decimal
'
,
notation
:
"
scientific
"
});
console
.
log
(
numfmt
.
format
(
1223
));
expect
(
numfmt
.
format
(
1223
)).
assertEqual
(
'
1.223E3
'
);
// console.log(numfmt.resolvedOptions().locale);
// console.log(numfmt.resolvedOptions().currency);
})
/* *
* @tc.number ARK_INTL_JS_DATETIME_003
* @tc.name format the number in ar-EG
* @tc.desc check the style of number in ar-EG
*/
it
(
'
numberFormat_info_test_003
'
,
0
,
function
()
{
var
number
=
123456.789
;
var
numfmt
=
new
Intl
.
NumberFormat
(
'
ar-EG
'
);
console
.
log
(
numfmt
.
format
(
number
));
expect
(
numfmt
.
format
(
number
)).
assertEqual
(
'
١٢٣٬٤٥٦٫٧٨٩
'
);
})
/* *
* @tc.number ARK_INTL_JS_DATETIME_004
* @tc.name format the number in en-IN
* @tc.desc check the format of number in en-IN
*/
it
(
'
numberFormat_info_test_004
'
,
0
,
function
()
{
var
number
=
123456.789
;
var
numfmt
=
new
Intl
.
NumberFormat
(
'
en-IN
'
);
console
.
log
(
numfmt
.
format
(
number
));
expect
(
numfmt
.
format
(
number
)).
assertEqual
(
'
1,23,456.789
'
);
})
/* *
* @tc.number ARK_INTL_JS_DATETIME_005
* @tc.name format the number in zh-Hans-CN-u-nu-hanidec
* @tc.desc check the format of number in zh-Hans-CN-u-nu-hanidec
*/
it
(
'
numberFormat_info_test_005
'
,
0
,
function
()
{
var
number
=
123456.789
;
// 通过编号系统中的nu扩展键请求, 例如中文十进制数字
var
numfmt
=
new
Intl
.
NumberFormat
(
'
zh-Hans-CN-u-nu-hanidec
'
)
console
.
log
(
numfmt
.
format
(
number
));
expect
(
numfmt
.
format
(
number
)).
assertEqual
(
'
一二三,四五六.七八九
'
)
})
/* *
* @tc.number ARK_INTL_JS_DATETIME_006
* @tc.name format the number in ban and id
* @tc.desc check the format of number in ban and id
*/
it
(
'
numberFormat_info_test_006
'
,
0
,
function
()
{
var
number
=
123456.789
;
var
numfmt
=
new
Intl
.
NumberFormat
(
'
ban
'
);
console
.
log
(
'
numberFormat_info_test_006
'
+
numfmt
.
format
(
number
));
expect
(
numfmt
.
format
(
number
)).
assertEqual
(
'
123,456.789
'
)
})
/* *
* @tc.number ARK_INTL_JS_DATETIME_008
* @tc.name format the number in ja-JP
* @tc.desc check the format of number in ja-JP
*/
it
(
'
numberFormat_info_test_008
'
,
0
,
function
()
{
var
number
=
123456.789
;
var
numfmt
=
new
Intl
.
NumberFormat
(
'
ja
'
,
{
style
:
'
currency
'
,
currency
:
'
JPY
'
});
console
.
log
(
'
numberFormat_info_test_008
'
+
numfmt
.
format
(
number
));
expect
(
numfmt
.
format
(
number
)).
assertEqual
(
'
¥123,457
'
);
})
/* *
* @tc.number ARK_INTL_JS_DATETIME_009
* @tc.name format the number in en-IN
* @tc.desc check the format of number in en-IN
*/
it
(
'
numberFormat_info_test_009
'
,
0
,
function
()
{
var
number
=
123456.789
;
var
numfmt
=
new
Intl
.
NumberFormat
(
'
en-IN
'
,
{
maximumSignificantDigits
:
3
})
console
.
log
(
'
numberFormat_info_test_009
'
+
numfmt
.
format
(
number
));
expect
(
numfmt
.
format
(
number
)).
assertEqual
(
'
1,23,000
'
)
})
})
\ No newline at end of file
compileruntime/ark_intl_standard/intljs/src/main/resources/base/element/string.json
0 → 100644
浏览文件 @
d27a7be9
{
"string"
:
[
{
"name"
:
"app_name"
,
"value"
:
"L2Test"
},
{
"name"
:
"mainability_description"
,
"value"
:
"JS_Phone_Empty Feature Ability"
}
]
}
\ No newline at end of file
compileruntime/ark_intl_standard/intljs/src/main/resources/base/media/icon.png
0 → 100644
浏览文件 @
d27a7be9
6.6 KB
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录