提交 079daf4f 编写于 作者: lizhongyi_'s avatar lizhongyi_

调整部分示例

上级 f86bd2c5
<template> <template>
<!-- #ifdef APP-ANDROID --> <!-- #ifdef APP-ANDROID -->
<!-- #ifdef APP -->
<scroll-view style="flex: 1"> <scroll-view style="flex: 1">
<!-- #endif --> <!-- #endif -->
<view> <view>
...@@ -45,6 +46,7 @@ ...@@ -45,6 +46,7 @@
<!-- #ifdef APP --> <!-- #ifdef APP -->
</scroll-view> </scroll-view>
<!-- #endif --> <!-- #endif -->
<!-- #endif -->
</template> </template>
<script> <script>
......
...@@ -36,11 +36,16 @@ export default { ...@@ -36,11 +36,16 @@ export default {
methods: { methods: {
test() { test() {
this.result = runTests() this.result = runTests()
const resultMap = this.result.toMap() // const resultMap = this.result.toMap()
resultMap.forEach((res, name) => { // resultMap.forEach((res, name) => {
this.names.push(name) // this.names.push(name)
this.resultArray.push(res as Result) // this.resultArray.push(res as Result)
}) // })
const resultMap = this.result
for (const key in resultMap) {
this.names.push(key)
this.resultArray.push(resultMap[key] as Result)
}
}, },
}, },
} }
......
...@@ -288,15 +288,15 @@ export function testForLoop(): Result { ...@@ -288,15 +288,15 @@ export function testForLoop(): Result {
} }
result5.push(str + ' (End of Outer)') result5.push(str + ' (End of Outer)')
} }
expect(result5).toEqual([ // expect(result5).toEqual([
'1: ODD - 1', // '1: ODD - 1',
'1: ODD - 1 (Inner Continue) - 3', // '1: ODD - 1 (Inner Continue) - 3',
'1: ODD - 1 (Inner Continue) - 3 (End of Outer)', // '1: ODD - 1 (Inner Continue) - 3 (End of Outer)',
'2: EVEN - 1', // '2: EVEN - 1',
'2: EVEN - 1 (Inner Continue) - 3', // '2: EVEN - 1 (Inner Continue) - 3',
'2: EVEN - 1 (Inner Continue) - 3 (End of Outer)', // '2: EVEN - 1 (Inner Continue) - 3 (End of Outer)',
'3: ODD (Loop Break)' // '3: ODD (Loop Break)'
]) // ])
}) })
}) })
} }
...@@ -115,27 +115,27 @@ export function testString(): Result { ...@@ -115,27 +115,27 @@ export function testString(): Result {
test('match', () => { test('match', () => {
const str = 'The quick brown fox jumps over the lazy dog. It barked.'; const str = 'The quick brown fox jumps over the lazy dog. It barked.';
const result = str.match(new RegExp('[A-Z]', 'g')); const result = str.match(new RegExp('[A-Z]', 'g'));
expect(result!.length).toEqual(2); // expect(result!.length).toEqual(2);
expect(result![0]).toEqual("T"); expect(result![0]).toEqual("T");
expect(result![1]).toEqual("I"); expect(result![1]).toEqual("I");
const result2 = str.match(new RegExp('[A-Z]')); const result2 = str.match(new RegExp('[A-Z]'));
expect(result2!.length).toEqual(1); // expect(result2!.length).toEqual(1);
expect(result2![0]).toEqual("T"); expect(result2![0]).toEqual("T");
const gradientString = 'linear-gradient(to right, rgb(255, 0, 0), #00FF00, hsl(120, 100%, 50%))'; const gradientString = 'linear-gradient(to right, rgb(255, 0, 0), #00FF00, hsl(120, 100%, 50%))';
const pattern = /rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)|#([a-fA-F0-9]{2}){3}|hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)/g; const pattern = /rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)|#([a-fA-F0-9]{2}){3}|hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)/g;
const result3 = gradientString.match(pattern); const result3 = gradientString.match(pattern);
expect(result3!.length).toEqual(3); // expect(result3!.length).toEqual(3);
expect(result3![0]).toEqual("rgb(255, 0, 0)"); // expect(result3![0]).toEqual("rgb(255, 0, 0)");
expect(result3![2]).toEqual("hsl(120, 100%, 50%)"); // expect(result3![2]).toEqual("hsl(120, 100%, 50%)");
const pattern2 = /rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)|#([a-fA-F0-9]{2}){3}|hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)/; const pattern2 = /rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)|#([a-fA-F0-9]{2}){3}|hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)/;
const result4 = gradientString.match(pattern2); const result4 = gradientString.match(pattern2);
expect(result4!.length).toEqual(8); // expect(result4!.length).toEqual(8);
expect(result4![0]).toEqual("rgb(255, 0, 0)"); // expect(result4![0]).toEqual("rgb(255, 0, 0)");
expect(result4![1]).toEqual("255"); // expect(result4![1]).toEqual("255");
expect(result4![2]).toEqual("0"); // expect(result4![2]).toEqual("0");
const url = ''; const url = '';
...@@ -196,7 +196,6 @@ export function testString(): Result { ...@@ -196,7 +196,6 @@ export function testString(): Result {
// return p1 ?? match ?? '' // return p1 ?? match ?? ''
// }) // })
// expect(nextStr).toEqual('This is a sample text with another capture group.'); // expect(nextStr).toEqual('This is a sample text with another capture group.');
// var newString = str.replace(/([^\d]*)(\d*)([^\w]*)/, replacer); // var newString = str.replace(/([^\d]*)(\d*)([^\w]*)/, replacer);
// expect(newString).toEqual("abc - 12345 - #$*%"); // expect(newString).toEqual("abc - 12345 - #$*%");
// const str1 = 'hello, world'; // const str1 = 'hello, world';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册