-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-case-sensitivity.ts
More file actions
55 lines (44 loc) · 1.76 KB
/
test-case-sensitivity.ts
File metadata and controls
55 lines (44 loc) · 1.76 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env bun
import { EAVStore, jsonEntityFacts } from '../src/eav-engine.js';
import { EQLSProcessor } from '../src/query/eqls-parser.js';
import { DatalogEvaluator } from '../src/query/datalog-evaluator.js';
console.log('🔍 Testing Case Sensitivity\n');
const sampleData = [
{ id: 1, title: "Hello World", views: 1500, reactions: { likes: 100 } },
{ id: 2, title: "TypeScript Guide", views: 2000, reactions: { likes: 1200 } },
{ id: 3, title: "Graph Theory", views: 800, reactions: { likes: 50 } }
];
const store = new EAVStore();
const processor = new EQLSProcessor();
const evaluator = new DatalogEvaluator(store);
// Load data
sampleData.forEach((item, index) => {
const entityId = `post:${item.id}`;
const facts = jsonEntityFacts(entityId, item, 'post');
store.addFacts(facts);
});
const catalog = store.getCatalog();
processor.setSchema(catalog);
// Test different cases
const testQueries = [
'FIND post AS ?p RETURN ?p', // lowercase post
'FIND POST AS ?p RETURN ?p', // uppercase POST
'FIND Post AS ?p RETURN ?p', // title case Post
];
for (const query of testQueries) {
console.log(`\n🧪 Testing: ${query}`);
const parseResult = processor.process(query);
if (parseResult.errors.length > 0) {
console.log('❌ Parse errors:');
parseResult.errors.forEach(error => {
console.log(` - ${error.message}`);
});
} else {
console.log('✅ Parse successful');
// Look at the first goal which should be the type constraint
const typeGoal = parseResult.query!.goals[0];
console.log('Type goal:', JSON.stringify(typeGoal));
const result = evaluator.evaluate(parseResult.query!);
console.log(`Results: ${result.bindings.length}`);
}
}