Exemple #1
0
static modification
test_modification (int i) {
  switch (i) {
  case  0: return mod_assign (path (), "Hi");
  case  1: return mod_insert (path (), 0, tree (TUPLE, "a", "b"));
  case  2: return mod_remove (path (), 0, 2);
  case  3: return mod_split (path (), 0, 1);
  case  4: return mod_join (path (), 0);
  case  5: return mod_assign_node (path (), TUPLE);
  case  6: return mod_insert_node (path (), 1, tree (TUPLE, "a", "b"));
  case  7: return mod_remove_node (path (), 0);

  case  8: return mod_insert (path (), 1, tree (TUPLE, "a", "b"));
  case  9: return mod_insert (path (), 2, tree (TUPLE, "a", "b"));
  case 10: return mod_remove (path (), 1, 2);
  case 11: return mod_remove (path (), 2, 2);
  case 12: return mod_split (path (), 1, 2);
  case 13: return mod_split (path (), 2, 1);
  case 14: return mod_join (path (), 1);
  case 15: return mod_join (path (), 2);
  case 16: return mod_remove_node (path (), 1);
  case 17: return mod_remove_node (path (), 2);

  case 18: case 19: case 20: case 21: case 22: case 23: case 24: case 25:
    return path (0) * test_modification (i-18);
  case 26: case 27: case 28: case 29: case 30: case 31: case 32: case 33:
    return path (1) * test_modification (i-26);
  case 34: case 35: case 36: case 37: case 38: case 39: case 40: case 41:
    return path (2) * test_modification (i-34);
  default:
    FAILED ("not implemented");
    return mod_assign (path (), "");
  }
}
Exemple #2
0
void
test_commute () {
  tree tt= test_tree ();
  for (int i=0; i<42; i++)
    for (int j=0; j<42; j++) {
      modification m1= test_modification (i);
      modification m2= test_modification (j);
      modification t1= m1;
      modification t2= m2;
      debug_std << "m1  = " << m1 << "\n";
      debug_std << "m2  = " << m2 << "\n";
      bool r= swap (m1, m2);
      modification u1= m1;
      modification u2= m2;
      if (!r) debug_std << "  Modifications do not commute\n\n";
      else {
	debug_std << "m1' = " << m1 << "\n";
	debug_std << "m2' = " << m2 << "\n";
	if (clean_apply (clean_apply (tt, t1), t2) !=
	    clean_apply (clean_apply (tt, m1), m2)) {
	  failed_error << "t1  = "
                       << clean_apply (clean_apply (tt, t1), t2) << "\n";
	  failed_error << "t2  = "
                       << clean_apply (clean_apply (tt, m1), m2) << "\n";
	  FAILED ("inconsistency");
	}
	r= swap (m1, m2);
	if (!r) debug_std << "r   = " << r << "\n";
	else if (m1 != t1 || m2 != t2) {
	  debug_std << "m1''= " << m1 << "\n";
	  debug_std << "m2''= " << m2 << "\n";
	  r= swap (m1, m2);
	  if (!r) debug_std << "r   = " << r << "\n";
	  else if (m1 != u1 || m2 != u2) {
	    debug_std << "m1* = " << m1 << "\n";
	    debug_std << "m2* = " << m2 << "\n";
	    r= false;
	  }
	}
	if (r) debug_std << "  Consistency check succeeded\n\n";
	else {
	  failed_error << "  Consistency check failed\n\n";
	  FAILED ("inconsistency");
	}
      }
    }
}
Exemple #3
0
void
test_invert () {
  tree t1= test_tree ();
  for (int i=0; i<42; i++) {
    modification m1= test_modification (i);
    tree t2= clean_apply (t1, m1);
    modification m2= invert (m1, t1);
    tree t3= clean_apply (t2, m2);
    modification m3= invert (m2, t2);
    if (m1 != m3 || t1 != t3) {
      cout << "t1= " << t1 << "\n";
      cout << "m1= " << m1 << "\n";
      cout << "t2= " << t2 << "\n";
      cout << "m2= " << m2 << "\n";
      cout << "t3= " << t3 << "\n";
      FAILED ("inconsistency");
    }
 }
}