feat: add toMatchUnorderedArrary matcher and apply it (#271)

* feat: add toMatchUnorderedArrary matcher replace tokenSuggestion test

* fix: revert benchmark and replace matcher of trinosql

---------

Co-authored-by: jialan <jialan@dtstack.com>
This commit is contained in:
JackWang032
2024-03-01 16:48:53 +08:00
committed by GitHub
parent 195878da9b
commit a05f099aa1
11 changed files with 136 additions and 48 deletions

View File

@ -19,7 +19,7 @@ describe('Flink SQL Token Suggestion', () => {
pos
)?.keywords;
expect(suggestion).toEqual(['MODULES', 'CATALOG']);
expect(suggestion).toMatchUnorderedArrary(['MODULES', 'CATALOG']);
});
test('Create Statement ', () => {
@ -32,7 +32,7 @@ describe('Flink SQL Token Suggestion', () => {
pos
)?.keywords;
expect(suggestion).toEqual([
expect(suggestion).toMatchUnorderedArrary([
'CATALOG',
'FUNCTION',
'TEMPORARY',
@ -52,7 +52,7 @@ describe('Flink SQL Token Suggestion', () => {
pos
)?.keywords;
expect(suggestion).toEqual([
expect(suggestion).toMatchUnorderedArrary([
'MODULES',
'FULL',
'FUNCTIONS',

View File

@ -18,7 +18,7 @@ describe('Hive SQL Token Suggestion', () => {
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toEqual([
expect(suggestion).toMatchUnorderedArrary([
'APPLICATION',
'GROUP',
'USER',
@ -45,7 +45,7 @@ describe('Hive SQL Token Suggestion', () => {
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toEqual([
expect(suggestion).toMatchUnorderedArrary([
'CONNECTOR',
'APPLICATION',
'GROUP',
@ -80,7 +80,7 @@ describe('Hive SQL Token Suggestion', () => {
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toEqual(['FROM']);
expect(suggestion).toMatchUnorderedArrary(['FROM']);
});
test('After DESCRIBE', () => {
@ -92,7 +92,7 @@ describe('Hive SQL Token Suggestion', () => {
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toEqual([
expect(suggestion).toMatchUnorderedArrary([
'EXTENDED',
'FORMATTED',
'FUNCTION',
@ -111,7 +111,7 @@ describe('Hive SQL Token Suggestion', () => {
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toEqual([
expect(suggestion).toMatchUnorderedArrary([
'CONNECTOR',
'APPLICATION',
'GROUP',
@ -141,7 +141,7 @@ describe('Hive SQL Token Suggestion', () => {
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toEqual(['TABLE']);
expect(suggestion).toMatchUnorderedArrary(['TABLE']);
});
test('After IMPORT', () => {
@ -153,7 +153,7 @@ describe('Hive SQL Token Suggestion', () => {
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toEqual(['FROM', 'TABLE', 'EXTERNAL']);
expect(suggestion).toMatchUnorderedArrary(['FROM', 'TABLE', 'EXTERNAL']);
});
test('After INSERT', () => {
@ -165,7 +165,7 @@ describe('Hive SQL Token Suggestion', () => {
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toEqual(['INTO', 'OVERWRITE']);
expect(suggestion).toMatchUnorderedArrary(['INTO', 'OVERWRITE']);
});
test('After LOAD', () => {
@ -177,7 +177,7 @@ describe('Hive SQL Token Suggestion', () => {
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toEqual(['DATA']);
expect(suggestion).toMatchUnorderedArrary(['DATA']);
});
test('After SHOW', () => {
@ -189,7 +189,7 @@ describe('Hive SQL Token Suggestion', () => {
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toEqual([
expect(suggestion).toMatchUnorderedArrary([
'CURRENT',
'ROLES',
'PRINCIPALS',

View File

@ -19,7 +19,7 @@ describe('Impala SQL Token Suggestion', () => {
pos
)?.keywords;
expect(suggestion).toEqual(['TABLE', 'VIEW', 'DATABASE']);
expect(suggestion).toMatchUnorderedArrary(['TABLE', 'VIEW', 'DATABASE']);
});
test('After CREATE', () => {
@ -32,7 +32,7 @@ describe('Impala SQL Token Suggestion', () => {
pos
)?.keywords;
expect(suggestion).toEqual([
expect(suggestion).toMatchUnorderedArrary([
'TABLE',
'EXTERNAL',
'VIEW',
@ -54,7 +54,7 @@ describe('Impala SQL Token Suggestion', () => {
pos
)?.keywords;
expect(suggestion).toEqual([
expect(suggestion).toMatchUnorderedArrary([
'DATABASE',
'SCHEMA',
'TABLE',
@ -77,7 +77,7 @@ describe('Impala SQL Token Suggestion', () => {
pos
)?.keywords;
expect(suggestion).toEqual(['INTO', 'OVERWRITE']);
expect(suggestion).toMatchUnorderedArrary(['INTO', 'OVERWRITE']);
});
test('After SHOW', () => {
@ -90,7 +90,7 @@ describe('Impala SQL Token Suggestion', () => {
pos
)?.keywords;
expect(suggestion).toEqual([
expect(suggestion).toMatchUnorderedArrary([
'DATABASES',
'SCHEMAS',
'TABLES',

View File

@ -19,7 +19,7 @@ describe('MySQL Token Suggestion', () => {
pos
)?.keywords;
expect(suggestion).toEqual([
expect(suggestion).toMatchUnorderedArrary([
'RESOURCE',
'USER',
'VIEW',
@ -50,7 +50,7 @@ describe('MySQL Token Suggestion', () => {
pos
)?.keywords;
expect(suggestion).toEqual([
expect(suggestion).toMatchUnorderedArrary([
'RESOURCE',
'USER',
'ROLE',
@ -91,7 +91,7 @@ describe('MySQL Token Suggestion', () => {
pos
)?.keywords;
expect(suggestion).toEqual(['FROM', 'IGNORE', 'QUICK', 'LOW_PRIORITY']);
expect(suggestion).toMatchUnorderedArrary(['FROM', 'IGNORE', 'QUICK', 'LOW_PRIORITY']);
});
test('After DESCRIBE', () => {
@ -104,7 +104,7 @@ describe('MySQL Token Suggestion', () => {
pos
)?.keywords;
expect(suggestion).toEqual([
expect(suggestion).toMatchUnorderedArrary([
'ANALYZE',
'SELECT',
'DELETE',
@ -128,7 +128,7 @@ describe('MySQL Token Suggestion', () => {
pos
)?.keywords;
expect(suggestion).toEqual([
expect(suggestion).toMatchUnorderedArrary([
'RESOURCE',
'USER',
'PREPARE',
@ -161,7 +161,13 @@ describe('MySQL Token Suggestion', () => {
pos
)?.keywords;
expect(suggestion).toEqual(['INTO', 'IGNORE', 'DELAYED', 'HIGH_PRIORITY', 'LOW_PRIORITY']);
expect(suggestion).toMatchUnorderedArrary([
'INTO',
'IGNORE',
'DELAYED',
'HIGH_PRIORITY',
'LOW_PRIORITY',
]);
});
test('After LOAD', () => {
@ -174,7 +180,7 @@ describe('MySQL Token Suggestion', () => {
pos
)?.keywords;
expect(suggestion).toEqual(['INDEX', 'XML', 'DATA']);
expect(suggestion).toMatchUnorderedArrary(['INDEX', 'XML', 'DATA']);
});
test('After SHOW', () => {
@ -187,7 +193,7 @@ describe('MySQL Token Suggestion', () => {
pos
)?.keywords;
expect(suggestion).toEqual([
expect(suggestion).toMatchUnorderedArrary([
'REPLICAS',
'REPLICA',
'SLAVE',

View File

@ -17,7 +17,7 @@ describe('Postgres SQL Token Suggestion', () => {
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toEqual([
expect(suggestion).toMatchUnorderedArrary([
'TYPE',
'TEXT',
'STATISTICS',
@ -66,7 +66,7 @@ describe('Postgres SQL Token Suggestion', () => {
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toEqual([
expect(suggestion).toMatchUnorderedArrary([
'RECURSIVE',
'VIEW',
'TEMPORARY',
@ -126,7 +126,7 @@ describe('Postgres SQL Token Suggestion', () => {
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toEqual(['FROM']);
expect(suggestion).toMatchUnorderedArrary(['FROM']);
});
test('After DROP', () => {
@ -138,7 +138,7 @@ describe('Postgres SQL Token Suggestion', () => {
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toEqual([
expect(suggestion).toMatchUnorderedArrary([
'OPERATOR',
'ROUTINE',
'PROCEDURE',
@ -188,6 +188,6 @@ describe('Postgres SQL Token Suggestion', () => {
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toEqual(['INTO']);
expect(suggestion).toMatchUnorderedArrary(['INTO']);
});
});

View File

@ -19,7 +19,7 @@ describe('Spark SQL Token Suggestion', () => {
pos
)?.keywords;
expect(suggestion).toEqual([
expect(suggestion).toMatchUnorderedArrary([
'TABLE',
'INDEX',
'VIEW',
@ -40,7 +40,7 @@ describe('Spark SQL Token Suggestion', () => {
pos
)?.keywords;
expect(suggestion).toEqual([
expect(suggestion).toMatchUnorderedArrary([
'TEMPORARY',
'INDEX',
'ROLE',
@ -67,7 +67,7 @@ describe('Spark SQL Token Suggestion', () => {
pos
)?.keywords;
expect(suggestion).toEqual(['FROM']);
expect(suggestion).toMatchUnorderedArrary(['FROM']);
});
test('After DESCRIBE', () => {
@ -80,7 +80,7 @@ describe('Spark SQL Token Suggestion', () => {
pos
)?.keywords;
expect(suggestion).toEqual([
expect(suggestion).toMatchUnorderedArrary([
'WITH',
'SELECT',
'MAP',
@ -106,7 +106,7 @@ describe('Spark SQL Token Suggestion', () => {
pos
)?.keywords;
expect(suggestion).toEqual([
expect(suggestion).toMatchUnorderedArrary([
'TEMPORARY',
'INDEX',
'ROLE',
@ -130,7 +130,7 @@ describe('Spark SQL Token Suggestion', () => {
pos
)?.keywords;
expect(suggestion).toEqual(['OVERWRITE', 'INTO']);
expect(suggestion).toMatchUnorderedArrary(['OVERWRITE', 'INTO']);
});
test('After LOAD', () => {
@ -143,7 +143,7 @@ describe('Spark SQL Token Suggestion', () => {
pos
)?.keywords;
expect(suggestion).toEqual(['DATA']);
expect(suggestion).toMatchUnorderedArrary(['DATA']);
});
test('After SHOW', () => {
@ -156,7 +156,7 @@ describe('Spark SQL Token Suggestion', () => {
pos
)?.keywords;
expect(suggestion).toEqual([
expect(suggestion).toMatchUnorderedArrary([
'LOCKS',
'INDEXES',
'TRANSACTIONS',
@ -195,6 +195,6 @@ describe('Spark SQL Token Suggestion', () => {
pos
)?.keywords;
expect(suggestion).toEqual(['TABLE']);
expect(suggestion).toMatchUnorderedArrary(['TABLE']);
});
});

View File

@ -19,7 +19,7 @@ describe('Trino SQL Token Suggestion', () => {
pos
)?.keywords;
expect(suggestion).toEqual(['VIEW', 'MATERIALIZED', 'TABLE', 'SCHEMA']);
expect(suggestion).toMatchUnorderedArrary(['VIEW', 'MATERIALIZED', 'TABLE', 'SCHEMA']);
});
test('After CREATE', () => {
@ -32,7 +32,14 @@ describe('Trino SQL Token Suggestion', () => {
pos
)?.keywords;
expect(suggestion).toEqual(['ROLE', 'VIEW', 'OR', 'MATERIALIZED', 'TABLE', 'SCHEMA']);
expect(suggestion).toMatchUnorderedArrary([
'ROLE',
'VIEW',
'OR',
'MATERIALIZED',
'TABLE',
'SCHEMA',
]);
});
test('After DEALLOCATE', () => {
@ -45,7 +52,7 @@ describe('Trino SQL Token Suggestion', () => {
pos
)?.keywords;
expect(suggestion).toEqual(['PREPARE']);
expect(suggestion).toMatchUnorderedArrary(['PREPARE']);
});
test('After DELETE', () => {
@ -58,7 +65,7 @@ describe('Trino SQL Token Suggestion', () => {
pos
)?.keywords;
expect(suggestion).toEqual(['FROM']);
expect(suggestion).toMatchUnorderedArrary(['FROM']);
});
test('After DESCRIBE', () => {
@ -71,7 +78,7 @@ describe('Trino SQL Token Suggestion', () => {
pos
)?.keywords;
expect(suggestion).toEqual(['OUTPUT', 'INPUT']);
expect(suggestion).toMatchUnorderedArrary(['OUTPUT', 'INPUT']);
});
test('After DROP', () => {
@ -84,7 +91,13 @@ describe('Trino SQL Token Suggestion', () => {
pos
)?.keywords;
expect(suggestion).toEqual(['ROLE', 'VIEW', 'MATERIALIZED', 'TABLE', 'SCHEMA']);
expect(suggestion).toMatchUnorderedArrary([
'ROLE',
'VIEW',
'MATERIALIZED',
'TABLE',
'SCHEMA',
]);
});
test('After INSERT', () => {
@ -97,6 +110,6 @@ describe('Trino SQL Token Suggestion', () => {
pos
)?.keywords;
expect(suggestion).toEqual(['INTO']);
expect(suggestion).toMatchUnorderedArrary(['INTO']);
});
});