import { DSLCompiler } from '../DSLCompiler.js';
import { Arbiter } from '../../core/Arbiter.js';

/**
 * Test with simple evidence containing predicate calls
 */
export function runSimpleEvidenceTest() {
  console.log('=== Simple Evidence Test ===\n');

  // Create arbiter instance
  const arbiter = new Arbiter();
  
  // Create compiler
  const compiler = new DSLCompiler(arbiter);

  // Simple evidence with predicate call
  const dsl = `
definition User {
  name: string
}

fact hasRole(user: User, role: string)

evidence canRead(user: User, doc: Document) {
  hasRole(user, 'admin')
}
  `;

  console.log('1. Compiling DSL with simple evidence...');
  try {
    const result = compiler.compile(dsl, 'simple-evidence');
    
    console.log('Result:', result.success ? 'SUCCESS' : 'FAILED');
    console.log('Generated rules:', result.generatedRules.size);
    console.log('Program evidence:', result.program.evidence.length);
    
    if (result.errors.length > 0) {
      console.log('Errors:', result.errors);
    }
    
    if (result.warnings.length > 0) {
      console.log('Warnings:', result.warnings);
    }
    
    return result;
  } catch (error) {
    console.error('Compilation failed:', error.message);
    return { success: false, error: error.message };
  }
}

// Run the test
runSimpleEvidenceTest();
