fix(i18n): chinese test suite (#38220)

* fix: Chinese test suite

Add localeTiltes, descriptions, and adjust test text and testStrings to get the automated test suite working.

* fix: ran script, updated testStrings and solutions
This commit is contained in:
Kristofer Koishigawa
2020-02-18 01:40:55 +09:00
committed by Mrugesh Mohapatra
parent 6a7a7e6d7d
commit b3213fc892
1264 changed files with 5635 additions and 4331 deletions

View File

@@ -18,11 +18,11 @@ localeTitle: 比较var的范围并让关键字
```yml
tests:
- text: <code>var</code>在代码中不存在。
testString: 'getUserInput => assert(!getUserInput("index").match(/var/g),"<code>var</code> does not exist in code.");'
testString: getUserInput => assert(!getUserInput('index').match(/var/g));
- text: 在if语句中声明的变量<code>i</code>应该等于“块范围”。
testString: 'getUserInput => assert(getUserInput("index").match(/(i\s*=\s*).*\s*.*\s*.*\1("|")block\s*scope\2/g), "The variable <code>i</code> declared in the if statement should equal "block scope".");'
testString: getUserInput => assert(getUserInput('index').match(/(i\s*=\s*).*\s*.*\s*.*\1('|")block\s*scope\2/g));
- text: <code>checkScope()</code>应该返回“函数范围”
testString: 'assert(checkScope() === "function scope", "<code>checkScope()</code> should return "function scope"");'
testString: assert(checkScope() === "function scope");
```

View File

@@ -18,7 +18,7 @@ localeTitle: 使用导出默认值创建导出回退
```yml
tests:
- text: 适当使用<code>export</code>回落。
testString: 'getUserInput => assert(getUserInput("index").match(/export\s+default\s+function\s+subtract\(x,y\)\s+{return\s+x\s-\s+y;}/g), "Proper used of <code>export</code> fallback.");'
testString: assert(code.match(/export\s+default\s+function(\s+subtract\s*|\s*)\(\s*x,\s*y\s*\)\s*{/g));
```

View File

@@ -18,13 +18,13 @@ localeTitle: 使用const关键字声明只读变量
```yml
tests:
- text: <code>var</code>在您的代码中不存在。
testString: 'getUserInput => assert(!getUserInput("index").match(/var/g),"<code>var</code> does not exist in your code.");'
testString: getUserInput => assert(!getUserInput('index').match(/var/g));
- text: <code>SENTENCE</code>应该是用<code>const</code>声明的常量变量。
testString: 'getUserInput => assert(getUserInput("index").match(/(const SENTENCE)/g), "<code>SENTENCE</code> should be a constant variable declared with <code>const</code>.");'
testString: getUserInput => assert(getUserInput('index').match(/(const SENTENCE)/g));
- text: <code>i</code>应该以<code>let</code>来宣布。
testString: 'getUserInput => assert(getUserInput("index").match(/(let i)/g), "<code>i</code> should be declared with <code>let</code>.");'
testString: getUserInput => assert(getUserInput('index').match(/(let i)/g));
- text: 应更改<code>console.log</code>以打印<code>SENTENCE</code>变量。
testString: 'getUserInput => assert(getUserInput("index").match(/console\.log\(\s*SENTENCE\s*\)\s*;?/g), "<code>console.log</code> should be adjusted to print the variable <code>SENTENCE</code>.");'
testString: getUserInput => assert(getUserInput('index').match(/console\.log\(\s*SENTENCE\s*\)\s*;?/g));
```

View File

@@ -23,11 +23,11 @@ localeTitle: 探索var和let关键字之间的差异
```yml
tests:
- text: <code>var</code>在代码中不存在。
testString: 'getUserInput => assert(!getUserInput("index").match(/var/g),"<code>var</code> does not exist in code.");'
testString: getUserInput => assert(!getUserInput('index').match(/var/g));
- text: <code>catName</code>应该是<code>Oliver</code> 。
testString: 'assert(catName === "Oliver", "<code>catName</code> should be <code>Oliver</code>.");'
testString: assert(catName === "Oliver");
- text: <code>quote</code>应该是<code>&quot;Oliver says Meow!&quot;</code>
testString: 'assert(quote === "Oliver says Meow!", "<code>quote</code> should be <code>"Oliver says Meow!"</code>");'
testString: assert(quote === "Oliver says Meow!");
```

View File

@@ -18,7 +18,7 @@ localeTitle: 导入默认导出
```yml
tests:
- text: 正确导入<code>export default</code>方法。
testString: 'getUserInput => assert(getUserInput("index").match(/import\s+subtract\s+from\s+"math_functions"/g), "Properly imports <code>export default</code> method.");'
testString: assert(code.match(/import\s+subtract\s+from\s+('|")\.\/math_functions\.js\1/g));
```

View File

@@ -18,13 +18,13 @@ localeTitle: 改变用const声明的数组
```yml
tests:
- text: 不要替换<code>const</code>关键字。
testString: 'getUserInput => assert(getUserInput("index").match(/const/g), "Do not replace <code>const</code> keyword.");'
testString: getUserInput => assert(getUserInput('index').match(/const/g));
- text: <code>s</code>应该是一个常量变量(使用<code>const</code> )。
testString: 'getUserInput => assert(getUserInput("index").match(/const\s+s/g), "<code>s</code> should be a constant variable (by using <code>const</code>).");'
testString: getUserInput => assert(getUserInput('index').match(/const\s+s/g));
- text: 不要更改原始数组声明。
testString: 'getUserInput => assert(getUserInput("index").match(/const\s+s\s*=\s*\[\s*5\s*,\s*7\s*,\s*2\s*\]\s*;?/g), "Do not change the original array declaration.");'
testString: getUserInput => assert(getUserInput('index').match(/const\s+s\s*=\s*\[\s*5\s*,\s*7\s*,\s*2\s*\]\s*;?/g));
- text: '<code>s</code>应该等于<code>[2, 5, 7]</code> 。'
testString: 'assert.deepEqual(s, [2, 5, 7], "<code>s</code> should be equal to <code>[2, 5, 7]</code>.");'
testString: assert.deepEqual(s, [2, 5, 7]);
```

View File

@@ -18,13 +18,13 @@ localeTitle: 防止对象突变
```yml
tests:
- text: 不要替换<code>const</code>关键字。
testString: 'getUserInput => assert(getUserInput("index").match(/const/g), "Do not replace <code>const</code> keyword.");'
testString: getUserInput => assert(getUserInput('index').match(/const/g));
- text: <code>MATH_CONSTANTS</code>应该是一个常量变量(使用<code>const</code> )。
testString: 'getUserInput => assert(getUserInput("index").match(/const\s+MATH_CONSTANTS/g), "<code>MATH_CONSTANTS</code> should be a constant variable (by using <code>const</code>).");'
testString: getUserInput => assert(getUserInput('index').match(/const\s+MATH_CONSTANTS/g));
- text: 请勿更改原始<code>MATH_CONSTANTS</code> 。
testString: 'getUserInput => assert(getUserInput("index").match(/const\s+MATH_CONSTANTS\s+=\s+{\s+PI:\s+3.14\s+};/g), "Do not change original <code>MATH_CONSTANTS</code>.");'
testString: getUserInput => assert(getUserInput('index').match(/const\s+MATH_CONSTANTS\s+=\s+{\s+PI:\s+3.14\s+};/g));
- text: <code>PI</code>等于<code>3.14</code> 。
testString: 'assert(PI === 3.14, "<code>PI</code> equals <code>3.14</code>.");'
testString: assert(PI === 3.14);
```

View File

@@ -18,11 +18,11 @@ localeTitle: 设置函数的默认参数
```yml
tests:
- text: '<code>increment(5, 2)</code>应为<code>7</code> 。'
testString: 'assert(increment(5, 2) === 7, "The result of <code>increment(5, 2)</code> should be <code>7</code>.");'
testString: assert(increment(5, 2) === 7);
- text: <code>increment(5)</code>的结果应为<code>6</code> 。
testString: 'assert(increment(5) === 6, "The result of <code>increment(5)</code> should be <code>6</code>.");'
testString: assert(increment(5) === 6);
- text: 默认参数<code>1</code>用于<code>value</code> 。
testString: 'getUserInput => assert(getUserInput("index").match(/value\s*=\s*1/g), "default parameter <code>1</code> was used for <code>value</code>.");'
testString: assert(code.match(/value\s*=\s*1/g));
```

View File

@@ -18,7 +18,7 @@ localeTitle: 使用*从文件导入所有内容
```yml
tests:
- text: 正确使用<code>import * as</code>语法。
testString: 'assert(code.match(/import\s+\*\s+as\s+[a-zA-Z0-9_$]+\s+from\s*"\s*capitalize_strings\s*"\s*;/gi), "Properly uses <code>import * as</code> syntax.");'
testString: assert(code.match(/import\s*\*\s*as\s+stringFunctions\s+from\s*('|")\.\/string_functions\.js\1/g));
```

View File

@@ -18,15 +18,15 @@ localeTitle: 使用箭头函数编写简明的匿名函数
```yml
tests:
- text: 用户确实替换了<code>var</code>关键字。
testString: 'getUserInput => assert(!getUserInput("index").match(/var/g), "User did replace <code>var</code> keyword.");'
testString: getUserInput => assert(!getUserInput('index').match(/var/g));
- text: <code>magic</code>应该是一个常量变量(通过使用<code>const</code> )。
testString: 'getUserInput => assert(getUserInput("index").match(/const\s+magic/g), "<code>magic</code> should be a constant variable (by using <code>const</code>).");'
testString: getUserInput => assert(getUserInput('index').match(/const\s+magic/g));
- text: <code>magic</code>是一种<code>function</code> 。
testString: 'assert(typeof magic === "function", "<code>magic</code> is a <code>function</code>.");'
testString: assert(typeof magic === 'function');
- text: <code>magic()</code>返回正确的日期。
testString: 'assert(magic().getDate() == new Date().getDate(), "<code>magic()</code> returns correct date.");'
testString: assert(magic().setHours(0,0,0,0) === new Date().setHours(0,0,0,0));
- text: <code>function</code>关键字未使用。
testString: 'getUserInput => assert(!getUserInput("index").match(/function/g), "<code>function</code> keyword was not used.");'
testString: getUserInput => assert(!getUserInput('index').match(/function/g));
```

View File

@@ -18,13 +18,13 @@ localeTitle: 使用类语法定义构造函数
```yml
tests:
- text: <code>Vegetable</code>应该是一个<code>class</code>具有限定<code>constructor</code>方法。
testString: 'assert(typeof Vegetable === "function" && typeof Vegetable.constructor === "function", "<code>Vegetable</code> should be a <code>class</code> with a defined <code>constructor</code> method.");'
testString: assert(typeof Vegetable === 'function' && typeof Vegetable.constructor === 'function');
- text: <code>class</code>关键字。
testString: 'getUserInput => assert(getUserInput("index").match(/class/g),"<code>class</code> keyword was used.");'
testString: assert(code.match(/class/g));
- text: <code>Vegetable</code>可以实例化。
testString: 'assert(() => {const a = new Vegetable("apple"); return typeof a === "object";},"<code>Vegetable</code> can be instantiated.");'
testString: assert(() => {const a = new Vegetable("apple"); return typeof a === 'object';});
- text: <code>carrot.name</code>应该返回<code>carrot</code> 。
testString: 'assert(carrot.name=="carrot","<code>carrot.name</code> should return <code>carrot</code>.");'
testString: assert(carrot.name=='carrot');
```

View File

@@ -18,11 +18,11 @@ localeTitle: 使用解构分配从数组中分配变量
```yml
tests:
- text: 交换后<code>a</code>值应为6。
testString: 'assert(a === 6, "Value of <code>a</code> should be 6, after swapping.");'
testString: assert(a === 6);
- text: 交换后<code>b</code>值应为8。
testString: 'assert(b === 8, "Value of <code>b</code> should be 8, after swapping.");'
testString: assert(b === 8);
- text: 使用数组解构来交换a和b。
testString: '// assert(/\[\s*(\w)\s*,\s*(\w)\s*\]\s*=\s*\[\s*\2\s*,\s*\1\s*\]/g.test(code), "Use array destructuring to swap a and b.");'
testString: assert(/\[\s*(\w)\s*,\s*(\w)\s*\]\s*=\s*\[\s*\2\s*,\s*\1\s*\]/g.test(code));
```

View File

@@ -18,11 +18,11 @@ localeTitle: 使用Spread运算符来就地评估数组
```yml
tests:
- text: <code>arr2</code>是<code>arr1</code>正确副本。
testString: 'assert(arr2.every((v, i) => v === arr1[i]), "<code>arr2</code> is correct copy of <code>arr1</code>.");'
testString: assert(arr2.every((v, i) => v === arr1[i]));
- text: <code>...</code>传播运算符用于复制<code>arr1</code> 。
testString: 'getUserInput => assert(getUserInput("index").match(/\[\s*...arr1\s*\]/g),"<code>...</code> spread operator was used to duplicate <code>arr1</code>.");'
testString: assert(code.match(/Array\(\s*\.\.\.arr1\s*\)|\[\s*\.\.\.arr1\s*\]/));
- text: 更改<code>arr1</code>时, <code>arr2</code>保持不变。
testString: 'assert((arr1, arr2) => {arr1.push("JUN"); return arr2.length < arr1.length},"<code>arr2</code> remains unchanged when <code>arr1</code> is changed.");'
testString: assert((arr1, arr2) => {arr1.push('JUN'); return arr2.length < arr1.length});
```

View File

@@ -18,15 +18,15 @@ localeTitle: 用参数写箭头函数
```yml
tests:
- text: 用户确实替换了<code>var</code>关键字。
testString: 'getUserInput => assert(!getUserInput("index").match(/var/g), "User did replace <code>var</code> keyword.");'
testString: getUserInput => assert(!getUserInput('index').match(/var/g));
- text: <code>myConcat</code>应该是一个常量变量(使用<code>const</code> )。
testString: 'getUserInput => assert(getUserInput("index").match(/const\s+myConcat/g), "<code>myConcat</code> should be a constant variable (by using <code>const</code>).");'
testString: getUserInput => assert(getUserInput('index').match(/const\s+myConcat/g));
- text: <code>myConcat</code>应该是一个函数
testString: 'assert(typeof myConcat === "function", "<code>myConcat</code> should be a function");'
testString: assert(typeof myConcat === 'function');
- text: <code>myConcat()</code>返回正确的<code>array</code>
testString: 'assert(() => { const a = myConcat([1], [2]); return a[0] == 1 && a[1] == 2; }, "<code>myConcat()</code> returns the correct <code>array</code>");'
testString: assert(() => { const a = myConcat([1], [2]); return a[0] == 1 && a[1] == 2; });
- text: <code>function</code>关键字未使用。
testString: 'getUserInput => assert(!getUserInput("index").match(/function/g), "<code>function</code> keyword was not used.");'
testString: getUserInput => assert(!getUserInput('index').match(/function/g));
```

View File

@@ -18,11 +18,11 @@ localeTitle: 用ES6编写简明的声明函数
```yml
tests:
- text: 未使用传统函数表达式。
testString: 'assert(!getUserInput("index").match(/function/),"Traditional <code>function</code> expression was not used.");'
testString: getUserInput => assert(!removeJSComments(code).match(/function/));
- text: <code>setGear</code>是一个声明函数。
testString: 'assert(typeof bicycle.setGear === "function" && getUserInput("index").match(/setGear\s*\(.+\)\s*\{/), "<code>setGear</code> is a declarative function.");'
- text: ''
testString: 'assert((new bicycle.setGear(48)).gear === 48, "<code>bicycle.setGear(48)</code> changes the <code>gear</code> value to 48.");'
testString: assert(typeof bicycle.setGear === 'function' && code.match(/setGear\s*\(.+\)\s*\{/));
- text: <code>bicycle.setGear(48)</code>应该返回48。
testString: assert((new bicycle.setGear(48)).gear === 48);
```

View File

@@ -18,9 +18,9 @@ localeTitle: 使用简单字段编写简明对象文字声明
```yml
tests:
- text: '输出是<code>{name: &quot;Zodiac Hasbro&quot;, age: 56, gender: &quot;male&quot;}</code> 。'
testString: 'assert(() => {const res={name:"Zodiac Hasbro",age:56,gender:"male"}; const person=createPerson("Zodiac Hasbro", 56, "male"); return Object.keys(person).every(k => person[k] === res[k]);}, "the output is <code>{name: "Zodiac Hasbro", age: 56, gender: "male"}</code>.");'
testString: assert(() => {const res={name:"Zodiac Hasbro",age:56,gender:"male"}; const person=createPerson("Zodiac Hasbro", 56, "male"); return Object.keys(person).every(k => person[k] === res[k]);});
- text: '不<code>:</code>被使用了。'
testString: 'getUserInput => assert(!getUserInput("index").match(/:/g), "No <code>:</code> were used.");'
testString: getUserInput => assert(!getUserInput("index").match(/:/g));
```