-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpatch-test.ts
42 lines (38 loc) · 925 Bytes
/
patch-test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { patchedTranslate, translate } from './client'
async function test(in_text: string, expected: string) {
console.log({ in_text })
let out_text = await translate({
source_lang: 'en',
target_lang: 'zh',
text: in_text,
})
console.log({ out_text })
let patched_out_text = await patchedTranslate({
source_lang: 'en',
target_lang: 'zh',
text: in_text,
})
console.log({ patched_out_text })
console.log({ match: patched_out_text === expected })
console.log()
}
async function loadTest() {
let res = await Promise.all(
new Array(300).fill(0).map(() =>
patchedTranslate({
source_lang: 'en',
target_lang: 'zh',
text: 'Transparent',
}),
),
)
console.log(res)
}
async function main() {
await test('Transparent', '透明')
await test('Contact', '联系人')
if (!'test') {
loadTest()
}
}
main().catch(e => console.error(e))