// Regression test for cross-file struct ("class") identity.
//
// Before the fix, the compiler encoded class types as the local class_num of
// the program being compiled. A simul_efun returning `class CrossStruct'
// baked in the simul_efun's class_num, while this caller has its own. The
// type check for `class CrossStruct foo = make_cross_struct(...)' rejected
// the assignment with "Bad assignment ( class  vs class  )" even though both
// sides referenced the structurally identical struct.

#include <cross_struct.h>

void do_tests() {
  // Bare simul_efun call returning a struct — must type-check and run.
  class CrossStruct cs = make_cross_struct(42, "hello");
  ASSERT(classp(cs));
  ASSERT_EQ(42, cs.n);
  ASSERT_EQ("hello", cs.s);

  // The locally-declared struct and the simul_efun's struct must be the
  // same type at runtime (same shape, same members).
  class CrossStruct local = new(class CrossStruct);
  local.n = cs.n;
  local.s = cs.s;
  ASSERT_EQ(local.n, cs.n);
  ASSERT_EQ(local.s, cs.s);
}
