set show timing off .
set show advisories off .

***
***	Check that the meta-interpreter doesn't use the meta-module cache.
***

fmod FOO is
  sort Foo .
  ops a b : -> Foo .
  eq a = b .
endfm

load metaInterpreter 

mod TEST is
  pr META-INTERPRETER .
  op me : -> Oid .
  op User : -> Cid .
  op state:_ : Nat -> Attribute .

  vars X Y Z : Oid .

  rl < X : User | state: 0 > createdInterpreter(X, Y, Z) =>
     < X : User | state: 1 > insertModule(Z, X, foo) .

  rl < X : User | state: 1 > insertedModule(X, Y) =>
     < X : User | state: 2 > insertModule(Y, X, bar) .

  rl < X : User | state: 2 > insertedModule(X, Y) =>
     < X : User | state: 3 > reduceTerm(Y, X, 'BAR, 'a.Foo) .

  op foo : -> Module .
  eq foo = (
fmod 'FOO is
  nil
  sorts 'Foo .
  none
  op 'a : nil -> 'Foo [none] .
  op 'c : nil -> 'Foo [none] .
  none
  eq 'a.Foo = 'c.Foo [none] .
endfm ) .

  op bar : -> Module .
  eq bar = (
fmod 'BAR is
  protecting 'FOO .
  sorts none .
  none
  none
  none
  none
endfm ) .
endm

*** correct result
erew  <> < me : User | state: 0 > createInterpreter(interpreterManager, me, none) .

*** put a fmod BAR with same meta-syntax but different semantics in cache
red metaReduce(bar, 'a.Foo) .

*** wrong result
erew  <> < me : User | state: 0 > createInterpreter(interpreterManager, me, none) .
