浏览代码

Fixed more generated tests.

Eugene Lazutkin 3 年之前
父节点
当前提交
77e9e211a5
共有 2 个文件被更改,包括 16 次插入97 次删除
  1. 5 47
      tests/test-jsonl-parser.mjs
  2. 11 50
      tests/test-jsonl-parserStream.mjs

+ 5 - 47
tests/test-jsonl-parser.mjs

@@ -49,53 +49,11 @@ const roundtrip = (t, resolve, len, quant) => {
 
 test.asPromise('jsonl parser: smoke test', (t, resolve) => roundtrip(t, resolve));
 
-test.asPromise('jsonl parser: roundtrip with 1 set of objects', (t, resolve) => {
-  roundtrip(t, resolve, 1);
-});
-
-test.asPromise('jsonl parser: roundtrip with 2 sets of objects', (t, resolve) => {
-  roundtrip(t, resolve, 2);
-});
-
-test.asPromise('jsonl parser: roundtrip with 3 sets of objects', (t, resolve) => {
-  roundtrip(t, resolve, 3);
-});
-
-test.asPromise('jsonl parser: roundtrip with 4 sets of objects', (t, resolve) => {
-  roundtrip(t, resolve, 4);
-});
-
-test.asPromise('jsonl parser: roundtrip with 5 sets of objects', (t, resolve) => {
-  roundtrip(t, resolve, 5);
-});
-
-test.asPromise('jsonl parser: roundtrip with 6 sets of objects', (t, resolve) => {
-  roundtrip(t, resolve, 6);
-});
-
-test.asPromise('jsonl parser: roundtrip with 7 sets of objects', (t, resolve) => {
-  roundtrip(t, resolve, 7);
-});
-
-test.asPromise('jsonl parser: roundtrip with 8 sets of objects', (t, resolve) => {
-  roundtrip(t, resolve, 8);
-});
-
-test.asPromise('jsonl parser: roundtrip with 9 sets of objects', (t, resolve) => {
-  roundtrip(t, resolve, 9);
-});
-
-test.asPromise('jsonl parser: roundtrip with 10 sets of objects', (t, resolve) => {
-  roundtrip(t, resolve, 10);
-});
-
-test.asPromise('jsonl parser: roundtrip with 11 sets of objects', (t, resolve) => {
-  roundtrip(t, resolve, 11);
-});
-
-test.asPromise('jsonl parser: roundtrip with 12 sets of objects', (t, resolve) => {
-  roundtrip(t, resolve, 12);
-});
+for (let i = 1; i <= 12; ++i) {
+  test.asPromise('jsonl parser: roundtrip with a set of objects - ' + i, (t, resolve) => {
+    roundtrip(t, resolve, i);
+  });
+}
 
 for (let i = 1; i <= 12; ++i) {
   test.asPromise('jsonl parser: roundtrip with different window sizes - ' + i, (t, resolve) => {

+ 11 - 50
tests/test-jsonl-parserStream.mjs

@@ -48,60 +48,21 @@ const roundtrip = (t, resolve, len, quant) => {
 
 test.asPromise('jsonl parserStream: smoke test', (t, resolve) => roundtrip(t, resolve));
 
-test.asPromise('jsonl parserStream: roundtrip with 1 set of objects', (t, resolve) => {
-  roundtrip(t, resolve, 1);
-});
-
-test.asPromise('jsonl parserStream: roundtrip with 2 sets of objects', (t, resolve) => {
-  roundtrip(t, resolve, 2);
-});
-
-test.asPromise('jsonl parserStream: roundtrip with 3 sets of objects', (t, resolve) => {
-  roundtrip(t, resolve, 3);
-});
-
-test.asPromise('jsonl parserStream: roundtrip with 4 sets of objects', (t, resolve) => {
-  roundtrip(t, resolve, 4);
-});
-
-test.asPromise('jsonl parserStream: roundtrip with 5 sets of objects', (t, resolve) => {
-  roundtrip(t, resolve, 5);
-});
-
-test.asPromise('jsonl parserStream: roundtrip with 6 sets of objects', (t, resolve) => {
-  roundtrip(t, resolve, 6);
-});
-
-test.asPromise('jsonl parserStream: roundtrip with 7 sets of objects', (t, resolve) => {
-  roundtrip(t, resolve, 7);
-});
-
-test.asPromise('jsonl parserStream: roundtrip with 8 sets of objects', (t, resolve) => {
-  roundtrip(t, resolve, 8);
-});
-
-test.asPromise('jsonl parserStream: roundtrip with 9 sets of objects', (t, resolve) => {
-  roundtrip(t, resolve, 9);
-});
-
-test.asPromise('jsonl parserStream: roundtrip with 10 sets of objects', (t, resolve) => {
-  roundtrip(t, resolve, 10);
-});
-
-test.asPromise('jsonl parserStream: roundtrip with 11 sets of objects', (t, resolve) => {
-  roundtrip(t, resolve, 11);
-});
-
-test.asPromise('jsonl parserStream: roundtrip with 12 sets of objects', (t, resolve) => {
-  roundtrip(t, resolve, 12);
-});
-
 for (let i = 1; i <= 12; ++i) {
-  test.asPromise('jsonl parserStream: roundtrip with different window sizes - ' + i, (t, resolve) => {
-    roundtrip(t, resolve, 10, i);
+  test.asPromise('jsonl parserStream: roundtrip with a set of objects - ' + i, (t, resolve) => {
+    roundtrip(t, resolve, i);
   });
 }
 
+for (let i = 1; i <= 12; ++i) {
+  test.asPromise(
+    'jsonl parserStream: roundtrip with different window sizes - ' + i,
+    (t, resolve) => {
+      roundtrip(t, resolve, 10, i);
+    }
+  );
+}
+
 test.asPromise('jsonl parserStream: read file', (t, resolve) => {
   if (!/^file:\/\//.test(import.meta.url)) throw Error('Cannot get the current working directory');
   const fileName = path.join(path.dirname(import.meta.url.substring(7)), './data/sample.jsonl.gz');