Exemple #1
0
bool DendrogramTest::run()
{
    context("triangle.pairs");
	Graph *graph = new Graph("data/triangle.pairs");
    Dendrogram *dendro = new Dendrogram(graph);
    testcase(dendro != NULL, "Initialized Dendrogram is NULL!");
    testcase(dendro->getRoot() != NULL, "Dendrogram has NULL root");
    testcase(((InternalNode *)(dendro->getRoot()))->getLeft() != NULL, "Dendrogram root has NULL left child");
    testcase(((InternalNode *)(dendro->getRoot()))->getRight() != NULL, "Dendrogram root has NULL right child");
    
    for (NodeList::iterator iterator=dendro->nodes.begin(); iterator!=dendro->nodes.end(); iterator++) {
        DendrogramNode *node = *iterator;
        
        if (node != dendro->getRoot()) {
            test_not_equal(node->parent,NULL,"Non-root node has NULL parent");
        }
        
        if (node->type == NODE_INTERNAL) {
            InternalNode *internal = (InternalNode *)node;
            if (internal->getLeft() != NULL) {
                test_equal(internal, internal->getLeft()->parent, "Left child of X does not have X as parent");
            }
            
            if (internal->getRight() != NULL) {
                test_equal(internal, internal->getRight()->parent, "Right child of X does not have X as parent");
            }
        }
    }
    
	delete dendro;
	delete graph;
    
    context("triangle.weights");
	graph = new Graph("data/triangle.weights");
    testcase(graph->isValid(), "failed to load valid graph from data/triangle.weights");
    dendro = new Dendrogram(graph);
    testcase(dendro != NULL, "Initialized Dendrogram is NULL!");
    testcase(dendro->getRoot() != NULL, "Dendrogram has NULL root");
    for (int i=0; i<100; i++) {
        dendro->sample();
    }
    testcase(dendro->likelihood() < 0.0f, "Invalid likelihood for post-sampled dendrogram");
    graph->addNode(99);
    graph->addEdge(99,1,0.9);
    std::set<Node> nodes_ab, nodes_z;
    nodes_ab.insert(1);
    nodes_ab.insert(2);
    nodes_z.insert(99);
    testcase(graph->linksBetween(nodes_ab,nodes_z) == 0.9, "Incorrect link weight between [A,B] , [Z]");
    dendro->addLeaf(99,1);
    testcase(graph->linksBetween(nodes_ab,nodes_z) == 0.9, "Incorrect link weight between [A,B] , [Z]");
	
	return this->didPass();
}
  Common_API bool from_str<bool> (const std::string& str)
  {
    bool match = false;
    boost::algorithm::is_equal test_equal;

    if ( test_equal(str,"true") ||
         test_equal(str,"True") ||
         test_equal(str,"on")   ||
         test_equal(str,"1")     )
    {
      return true;
    }

    if ( test_equal(str,"false") ||
         test_equal(str,"False") ||
         test_equal(str,"off")   ||
         test_equal(str,"0")      )
    {
      return false;
    }

    if (!match)
      throw ParsingFailed (FromHere(), "Incorrect option conversion to bool of string [" + str + "]" );
    return true;
  }
Exemple #3
0
static void test_specific(PeriodType pt, guint16 mult,
                          GDateMonth sm, GDateDay sd, GDateYear sy,
                          GDateMonth rm, GDateDay rd, GDateYear ry,
                          GDateMonth nm, GDateDay nd, GDateYear ny)
{
    GDate start;
    GDate ref, next, true_next;
    Recurrence r;

    g_date_set_dmy(&start, sd, sm, sy);
    g_date_set_dmy(&ref, rd, rm, ry);
    g_date_set_dmy(&true_next, nd, nm, ny);


    recurrenceSet(&r, mult, pt, &start, WEEKEND_ADJ_NONE);
    recurrenceNextInstance(&r, &ref, &next);

    check_valid(&next, &ref, &start, mult, pt, WEEKEND_ADJ_NONE);
    if (!test_equal(&next, &true_next))
    {
        gchar s1[21], s2[21], s3[21];
        g_date_strftime(s1, 20, "%x", &start);
        g_date_strftime(s2, 20, "%x", &ref);
        g_date_strftime(s3, 20, "%x", &true_next);
        printf("pt = %d; mult = %d; start = %s; ref = %s; true_next = %s\n",
               pt, mult, s1, s2, s3);
    }
}
Exemple #4
0
int equals_after_stack_free()
{
  int * x = leak_pointer();
  int * y = malloc(sizeof(int));
  if( test_equal( x, y ) ) { puts("EQ!"); }
  return 1;
}
Exemple #5
0
int
main(void)
{
    test_equal();

    test_overflow();

    lzma_index *i = create_empty();
    test_many(i);
    lzma_index_end(i, NULL);

    i = create_small();
    test_many(i);
    lzma_index_end(i, NULL);

    i = create_big();
    test_many(i);
    lzma_index_end(i, NULL);

    test_cat();

    test_locate();

    test_corrupt();

    return 0;
}
Exemple #6
0
int
main()
{
  init_random_ness ();
  test_area ();
  test_intersect ();
  test_equal ();
  test_overlap_funcs ();
  test_basic_fitting ();

  test_regions_okay ();
  test_region_fitting ();

  test_clamping_to_region ();
  test_clipping_to_region ();
  test_shoving_into_region ();

  /* And now the functions dealing with edges more than boxes */
  test_find_onscreen_edges ();
  test_find_nonintersected_monitor_edges ();

  /* And now the misfit functions that don't quite fit in anywhere else... */
  test_gravity_resize ();
  test_find_closest_point_to_line ();

  printf ("All tests passed.\n");
  return 0;
}
Exemple #7
0
int equals_after_free()
{
  volatile int* x = malloc(sizeof(int));
  *x = 12;
  free((int*) x);
  if( test_equal( (void*) x, (void*) x) ) { puts("EQ!"); }
  return 1;
}
 // test if all threads have arrived
 KOKKOS_INLINE_FUNCTION
 static bool try_wait( int * buffer
                     , const int size
                     , const int step
                     ) noexcept
 {
   if (size <= 1) return true;
   return test_equal( buffer + wait_idx, step );
 }
Exemple #9
0
int main()
{
	int Error = 0;

	Error += test_equal();
	Error += test_notEqual();

	return Error;
}
Exemple #10
0
int
sc_main( int, char*[] )
{
    sc_bv<4> bv_one( "0101" );
    sc_bv<4> bv_two( "1010" );

    test_smaller( bv_one, bv_two );
    test_equal( bv_one, bv_two );
    test_larger( bv_one, bv_two );

    return 0;
}
Exemple #11
0
int
sc_main( int, char*[] )
{
    sc_lv<4> lv_one( "01ZX" );
    sc_lv<4> lv_two( "1010" );

    test_smaller( lv_one, lv_two );
    test_equal( lv_one, lv_two );
    test_larger( lv_one, lv_two );

    return 0;
}
Exemple #12
0
static void test_ffs()
{
	char str_buf[128] = {0};
	uint8_t s = BIT(3) | BIT(6) | BIT(0) | BIT(7);
	int results[4] = {1, 4, 7, 8};

	for (int i = 0; i < 4; i++) {
		int ret = ffs(s);
		test_equal(results[i], ret);
		printf("%02x(%s) -> %d\n", s, bin_str(&s, 1, str_buf, 128), ret);
		s &= ~BIT((ret - 1));
	}
}
Exemple #13
0
int main(int argc , char ** argv) {
  create_test();
  get_test();
  set_test();
  load_empty_test();
  test_equal();
  test_copy();
  test_io();
  test_update_undefined( );
  test_select_matching();
  test_count_matching();
  exit(0);
}
int main()
{
	int Error = 0;

	Error += test_lessThan();
	Error += test_lessThanEqual();
	Error += test_greaterThan();
	Error += test_greaterThanEqual();
	Error += test_equal();
	Error += test_notEqual();
	Error += test_any();
	Error += test_all();
	Error += test_not();

	return Error;
}
void test(){
	test_sum();
	test_max();
	test_min();
	test_second_max();
	test_second_min();
	test_equal();
	test_occurences();
	test_countNegatives();
	test_indexOf();
	test_clearWith();
	test_insertElement();
	test_removeElement();
	test_copy();
	test_merge();
	test_reverse();
	test_sort();
	printf("All passed!!!!");
}
int
main(void)
{
	test_equal();

	test_overflow();

	lzma_index *i = create_empty();
	test_many(i);
	lzma_index_end(i, NULL);

	i = create_small();
	test_many(i);
	lzma_index_end(i, NULL);

	i = create_big();
	test_many(i);
	lzma_index_end(i, NULL);

	test_cat();

	test_locate();

	test_corrupt();

	// Test for the bug fix 21515d79d778b8730a434f151b07202d52a04611:
	// liblzma: Fix lzma_index_dup() for empty Streams.
	i = create_empty();
	expect(lzma_index_stream_padding(i, 4) == LZMA_OK);
	test_copy(i);
	lzma_index_end(i, NULL);

	// Test for the bug fix 3bf857edfef51374f6f3fffae3d817f57d3264a0:
	// liblzma: Fix a memory leak in error path of lzma_index_dup().
	// Use Valgrind to see that there are no leaks.
	i = create_small();
	expect(lzma_index_dup(i, &my_allocator) == NULL);
	lzma_index_end(i, NULL);

	return 0;
}
Exemple #17
0
int main()
{
   test_symbol();
   test_integer();
   test_cell();
   test_list();
   test_environment();
   test_eval();
   test_plus_integer();
   test_begin();
   test_string();
   test_tokenize();
   test_newlispobj();
   test_expandreadmacro();
   test_read_tokens();
   test_macro();
   test_equal();
   test_cond();

   return 0;
}
Exemple #18
0
/* Find node in node_map, if not found , generate a leaf node. */
DAG_node * DAG_graph::find_node(Symbol_item * item){
	std::map<Symbol_item *  ,DAG_node *>::iterator iter = node_map.find(item);
	if(iter != node_map.end()){
		return iter->second;
	}
	/* For constant find by value. */
	if(item->get_kind()==Symbol_item::TEMP_CON||item->get_kind()==Symbol_item::CONST){
		std::map<Symbol_item *  ,DAG_node *>::iterator m_iter = node_map.begin();
		while(m_iter!= node_map.end()){
			Symbol_item * tmp_item= m_iter->first;
			DAG_node * node = m_iter->second;
			if(test_equal(tmp_item, item))
				return node;
			m_iter++;
		}
	}

	DAG_node * node = new DAG_node(item, ++count);
	node_list.push_back(node);
	return node;
}
Exemple #19
0
int t_map()
{
	c_map map;

	c_map_create(&map, int_comparer);

	
	assert(__c_rb_tree_verify(map._l));
	printf("0. test create with insert unique\n");
	create_with_insert_unique(&map);
	print_map(&map);
	rprint_map(&map);
	assert(__c_rb_tree_verify(map._l));

	printf("\n\n1. test clear\n");
	test_clear(&map);
	assert(__c_rb_tree_verify(map._l));

	printf("\n\n2. test size and empty\n");
	test_size_empty(&map);
	assert(__c_rb_tree_verify(map._l));

	printf("\n\n3. test create with insert equal\n");
	c_map_clear(&map);
	create_with_insert_equal(&map);
	print_map(&map);
	rprint_map(&map);
	assert(__c_rb_tree_verify(map._l));

	printf("\n\n4. test swap\n");
	create_with_insert_unique(&map);
	test_swap(&map);
	assert(__c_rb_tree_verify(map._l));

	printf("\n\n5. test create with insert unique1\n");
	create_with_insert_unique1(&map);
	print_map(&map);
	rprint_map(&map);
	assert(__c_rb_tree_verify(map._l));

	printf("\n\n6. test create with insert equal1\n");
	c_map_clear(&map);
	create_with_insert_equal1(&map);
	print_map(&map);
	rprint_map(&map);
	assert(__c_rb_tree_verify(map._l));

	printf("\n\n7. test create with insert unique2\n");
	c_map_clear(&map);
	create_with_insert_unique2(&map);
	print_map(&map);
	rprint_map(&map);
	assert(__c_rb_tree_verify(map._l));

	printf("\n\n8. test create with insert equal2\n");
	c_map_clear(&map);
	create_with_insert_equal2(&map);
	print_map(&map);
	rprint_map(&map);
	assert(__c_rb_tree_verify(map._l));
	
	printf("\n\n9. test erase\n");
	c_map_clear(&map);
	create_with_insert_unique(&map);
	test_erase(&map);
	create_with_insert_unique(&map);	
	test_reverse_erase(&map);	
	print_map(&map);
	assert(__c_rb_tree_verify(map._l));

	printf("\n\n10. test find and erase\n");
	c_map_clear(&map);
	printf("* test_find_erase:\n");
	create_with_insert_unique(&map);
	print_map(&map);	
	test_find_erase(&map);
	print_map(&map);	
	printf("* test_reverse_find_erase:\n");
	create_with_insert_unique(&map);
	print_map(&map);	
	test_reverse_find_erase(&map);
	print_map(&map);	
	assert(__c_rb_tree_verify(map._l));

	printf("\n\n11. test count:\n"); // 'lower_bound' 'upper_bound' 'equal_range' used	
	create_with_insert_unique(&map);
	test_count(&map);

	printf("\n\n12. test less:\n");
	test_less();

	printf("\n\n13. test equal:\n");
	test_equal();

	printf("\n\n14. test at:\n");
	test_at();
	
	c_map_destroy(&map);
	printf("\n\nfinish testing map!\n");
	return 0;
}
Exemple #20
0
int main(int argc , char ** argv) {
  basic_test();
  test_equal();
  test_copy();
  exit(0);
}
Exemple #21
0
int main()
{
	printf("***** build time %s %s %d %s *****\n", __TIME__,__DATE__,__GNUC__,__VERSION__);

    test_equal(mask_value(0xf0, BIT(0)), 0);
    test_equal(mask_value(0xf0, BIT(1)), 0);
    test_equal(mask_value(0xf0, BIT(2)), 0);
    test_equal(mask_value(0xf0, BIT(3)), 0);
    test_equal(mask_value(0xf0, BIT(4)), 1);
    test_equal(mask_value(0xf0, BIT(5)), 1);
    test_equal(mask_value(0xf0, BIT(6)), 1);
    test_equal(mask_value(0xf0, BIT(7)), 1);

    test_equal(mask_value(0xf0, BIT(2) | BIT(3)), 0);
    test_equal(mask_value(0xf0, BIT(3) | BIT(4)), 2);
    test_equal(mask_value(0xf0, BIT(4) | BIT(5)), 3);
    test_equal(mask_value(0xf0, BIT(6) | BIT(7)), 3);

    test_equal(BIT_MASK(3, 5), 0x38);
    test_equal(BIT_MASK(3, 6), 0x78);
    test_equal(BIT_MASK(4, 7), 0xf0);

    test_equal(mask_value(0xf0, BIT_MASK(2, 3)), 0);
    test_equal(mask_value(0xf0, BIT_MASK(3, 4)), 2);
    test_equal(mask_value(0xf0, BIT_MASK(4, 5)), 3);
    test_equal(mask_value(0xf0, BIT_MASK(6, 7)), 3);
    test_equal(mask_value(0xf0, BIT_MASK(3, 5)), 6);
    test_equal(mask_value(0xf0, BIT_MASK(3, 6)), 0xe);
    test_equal(mask_value(0xf0, BIT_MASK(4, 7)), 0xf);

	test_ffs();

    return 0;
}
Exemple #22
0
void test_do(test_context_t *test)
{
    
    bitset_t *set;
    int i;
    
    
    test_mark(test, "bitset functions");
    test_group_start(test, "Setup and sanity check");
    {
        
        set = bitset_init(SET_SIZE);
        test_not_null(test, "Sanity check: allocated bitset", set);
               
    }
    test_group_end(test);
    
    
    test_group_start(test, "set / get");
    {
        int set1[6] = { 0, 1, 3, 5, SET_SIZE -1, SET_SIZE - 3 };
        int set2[6] = { 2, 4, 6, 10, 11, SET_SIZE - 2 };
        
        /* set1 is TRUE, set2 is false */
        for(i = 0; i < 6; i++) bitset_set(set, set1[i], TRUE);
        for(i = 0; i < 6; i++) bitset_set(set, set2[i], FALSE);
        
        /* now check it */        
        for(i = 0; i < 6; i++) {
            test_equal(test, "set1 members are TRUE", bitset_get(set, set1[i]), TRUE);
            test_equal(test, "set2 members are FALSE", bitset_get(set, set2[i]), FALSE);
        }
        
        /* reverse it and try it again */
        for(i = 0; i < 6; i++) bitset_set(set, set1[i], FALSE);
        for(i = 0; i < 6; i++) bitset_set(set, set2[i], TRUE);
        
        for(i = 0; i < 6; i++) {
            test_equal(test, "set1 members are FALSE (2)", bitset_get(set, set1[i]), FALSE);
            test_equal(test, "set2 members are TRUE  (2)", bitset_get(set, set2[i]), TRUE);
        }
    }
    test_group_end(test);
    
 
    test_group_start(test, "set all");
    {
        
        /* ALL TRUE */
        bitset_set_all(set, TRUE);
        bitset_set(set, 5, FALSE); /* special one to catch stuck-on bugs ? */
        
        for(i = 0; i < SET_SIZE; i++) {
            if(i != 5)
                test_equal(test, "set_all (TRUE)", bitset_get(set, i), TRUE);
            else
                test_equal(test, "set_all (one is FALSE)", bitset_get(set, i), FALSE);
        }
        
        /* ALL FALSE */
        bitset_set_all(set, FALSE);
        bitset_set(set, 31, TRUE); /* see above */
        
        for(i = 0; i < SET_SIZE; i++) {
            if(i != 31)
                test_equal(test, "set_all (FALSE)", bitset_get(set, i), FALSE);
            else
                test_equal(test, "set_all (one is TRUE)", bitset_get(set, i), TRUE);
        }
        
        
    }
    test_group_end(test);    

}
Exemple #23
0
int main(int argc, char *argv[])
{
    int ans;
    char *str, *strout;
    
    fmpz_poly_t zpoly;
    fmpz_poly_q_t qpoly1;
    
    mpz_t mpzzero, mpzone, mpztwo;
    mpq_t mpqzero, mpqone, mpqtwo, mpqtwoinv;
    
    FLINT_TEST_INIT(state);
    
    flint_printf("all... ");
    fflush(stdout);
    
    /* Accessing numerator and denominator ***********************************/
    
    fmpz_poly_q_init(qpoly1);
    fmpz_poly_q_set_str(qpoly1, "2  -1 1/2  0 1");
    str = "2  -1 1";
    strout = fmpz_poly_get_str(fmpz_poly_q_numref(qpoly1));
    ans = !strcmp(str, strout);
    if (!ans)
    {
        flint_printf("test_numref: failed\n");
        flint_printf("    Expected \"%s\", got \"%s\"\n", str, strout);
        flint_printf("    qpoly1 = \""), fmpz_poly_q_print(qpoly1), flint_printf("\"\n");
        abort();
    }
    fmpz_poly_q_clear(qpoly1);
    flint_free(strout);
    
    fmpz_poly_q_init(qpoly1);
    fmpz_poly_q_set_str(qpoly1, "2  -1 1/2  0 1");
    str = "2  0 1";
    strout = fmpz_poly_get_str(fmpz_poly_q_denref(qpoly1));
    ans = !strcmp(str, strout);
    if (!ans)
    {
        flint_printf("test_denref: failed\n");
        flint_printf("    Expected \"%s\", got \"%s\"\n", str, strout);
        abort();
    }
    fmpz_poly_q_clear(qpoly1);
    flint_free(strout);
    
    fmpz_poly_q_init(qpoly1);
    fmpz_poly_init(zpoly);
    fmpz_poly_q_set_str(qpoly1, "2  -1 1/2  0 1");
    fmpz_poly_set(zpoly, fmpz_poly_q_numref(qpoly1));
    str = "2  -1 1";
    strout = fmpz_poly_get_str(zpoly);
    ans = !strcmp(str, strout);
    if (!ans)
    {
        flint_printf("test_get_num: failed\n");
        flint_printf("    Expected \"%s\", got \"%s\"\n", str, strout);
        abort();
    }
    fmpz_poly_q_clear(qpoly1);
    fmpz_poly_clear(zpoly);
    flint_free(strout);
    
    fmpz_poly_q_init(qpoly1);
    fmpz_poly_init(zpoly);
    fmpz_poly_q_set_str(qpoly1, "2  -1 1/2  0 1");
    fmpz_poly_set(zpoly, fmpz_poly_q_denref(qpoly1));
    
    str = "2  0 1";
    strout = fmpz_poly_get_str(zpoly);
    ans = !strcmp(str, strout);
    if (!ans)
    {
        flint_printf("test_get_den: failed\n");
        flint_printf("    Expected \"%s\", got \"%s\"\n", str, strout);
        abort();
    }
    fmpz_poly_q_clear(qpoly1);
    fmpz_poly_clear(zpoly);
    flint_free(strout);
    
    fmpz_poly_q_init(qpoly1);
    fmpz_poly_init(zpoly);
    fmpz_poly_q_set_str(qpoly1, "1  1/1  1");
    fmpz_poly_set_str(zpoly, "2  0 1");
    fmpz_poly_set(fmpz_poly_q_numref(qpoly1), zpoly);
    str = "2  0 1";
    strout = fmpz_poly_get_str(fmpz_poly_q_numref(qpoly1));
    ans = !strcmp(str, strout);
    if (!ans)
    {
        flint_printf("test_set_num: failed\n");
        flint_printf("    Expected \"%s\", got \"%s\"\n", str, strout);
        abort();
    }
    fmpz_poly_q_clear(qpoly1);
    fmpz_poly_clear(zpoly);
    flint_free(strout);
    
    fmpz_poly_q_init(qpoly1);
    fmpz_poly_init(zpoly);
    fmpz_poly_q_set_str(qpoly1, "1  1/1  1");
    fmpz_poly_set_str(zpoly, "2  0 1");
    fmpz_poly_set(fmpz_poly_q_denref(qpoly1), zpoly);
    str = "2  0 1";
    strout = fmpz_poly_get_str(fmpz_poly_q_denref(qpoly1));
    ans = !strcmp(str, strout);
    if (!ans)
    {
        flint_printf("test_set_den: failed\n");
        flint_printf("    Expected \"%s\", got \"%s\"\n", str, strout);
        abort();
    }
    fmpz_poly_q_clear(qpoly1);
    fmpz_poly_clear(zpoly);
    flint_free(strout);
    
    /* Canonicalise **********************************************************/
    
    fmpz_poly_q_init(qpoly1);
    str = "2  -1 1/2  0 1";
    fmpz_poly_q_set_str(qpoly1, str);
    strout = fmpz_poly_q_get_str(qpoly1);
    ans = !strcmp(str, strout);
    if (!ans)
    {
        flint_printf("test_canonicalize: failed\n");
        flint_printf("    Expected \"%s\", got \"%s\"\n", str, strout);
        abort();
    }
    fmpz_poly_q_clear(qpoly1);
    flint_free(strout);
    
    fmpz_poly_q_init(qpoly1);
    str = "2  -1 -1/2  0 1";
    fmpz_poly_q_set_str(qpoly1, "2  1 1/2  0 -1");
    strout = fmpz_poly_q_get_str(qpoly1);
    ans = !strcmp("2  -1 -1/2  0 1", strout);
    if (!ans)
    {
        flint_printf("test_canonicalize: failed\n");
        flint_printf("    Expected \"%s\", got \"%s\"\n", str, strout);
        abort();
    }
    flint_free(strout);
    fmpz_poly_q_clear(qpoly1);
    
    /* Initialization, memory management and basic operations ****************/
    
    test_set("0", "0");
    test_set("0/1  1", "0");
    test_set("3  -1 0 1/2  0 1", "3  -1 0 1/2  0 1");
    test_set("3  -1 0 1/2  1 1", "2  -1 1");
    
    test_set_si(-1, "1  -1");
    test_set_si(13, "1  13");
    test_set_si(0, "0");
    
    test_swap("3  -1 0 1/2  0 1", "1  2/1  3", "1  2/1  3", "3  -1 0 1/2  0 1");
    
    test_zero("0", "0");
    test_zero("0/1  1", "0");
    test_zero("3  -1 0 1/2  0 1", "0");
    
    test_neg("0", "0");
    test_neg("1  1/1  2", "1  -1/1  2");
    test_neg("3  -1 0 1/2  0 1", "3  1 0 -1/2  0 1");
    
    test_inv("1  1/1  2", "1  2");
    test_inv("3  -1 0 1/2  0 1", "2  0 1/3  -1 0 1");
    test_inv("3  -1 0 -1/2  0 1", "2  0 -1/3  1 0 1");
    
    test_inv_inplace("1  1/1  2", "1  2");
    test_inv_inplace("3  -1 0 1/2  0 1", "2  0 1/3  -1 0 1");
    test_inv_inplace("3  -1 0 -1/2  0 1", "2  0 -1/3  1 0 1");
    
    test_is_zero("0", 1);
    test_is_zero("0/1  1", 1);
    test_is_zero("3  -1 0 1/2  0 1", 0);
    test_is_zero("3  -1 0 1/2  1 1", 0);
    
    test_is_one("0", 0);
    test_is_one("0/1  1", 0);
    test_is_one("1  1/1  1", 1);
    test_is_one("2  1 1/2  1 1", 1);
    test_is_one("3  -1 0 1/2  0 1", 0);
    
    test_equal("1  1/1  2", "1  1/1  2", 1);
    test_equal("1  1/1  2", "1  1/1  2", 1);
    test_equal("3  -1 0 1/2  1 1", "2  -1 1", 1);
    test_equal("3  -1 0 1/2  -1 1", "2  -1 1", 0);
    
    /* Addition and subtraction **********************************************/
    
    test_add("3  1 0 1/2  0 1", "2  0 -1/3  1 0 1", "5  1 0 1 0 1/4  0 1 0 1");
    test_add("3  -1 0 1/2  1 1", "1  2/2  -1 1", "3  3 -2 1/2  -1 1");
    test_add("0/2  1 1", "1  2/1  1", "1  2");
    test_add("1  -3/1  4", "0/3  1 0 1", "1  -3/1  4");
    test_add("2  1 1/1  1", "2  -1 1/1  1", "2  0 2");
    test_add("2  1 1/2  0 1", "2  2 1/2  -1 1", "3  -1 2 2/3  0 -1 1");
    test_add("2  -1 1/2  2 1", "3  4 4 1/2  1 1", "4  7 12 7 1/3  2 3 1");
    test_add("2  1 1/2  -1 1", "2  1 1", "3  0 1 1/2  -1 1");
    test_add("1  1/2  1 1", "2  0 1/2  1 1", "1  1");
    test_add("2  1 1/3  4 -4 1", "1  1/2  -2 1", "2  -1 2/3  4 -4 1");
    test_add("3  0 1 1/3  1 2 1", "2  0 -1/2  1 1", "0");
    test_add("2  1 1/2  0 1", "2  -1 1/2  0 1", "1  2");
    test_add("1  1/3  3 5 2", "1  1/3  6 7 2", "1  1/3  2 3 1");
    
    test_add_in_place1("3  1 0 1/2  0 1", "2  0 -1/3  1 0 1", "5  1 0 1 0 1/4  0 1 0 1");
    test_add_in_place1("3  -1 0 1/2  1 1", "1  2/2  -1 1", "3  3 -2 1/2  -1 1");
    test_add_in_place1("0/2  1 1", "1  2/1  1", "1  2");
    test_add_in_place1("1  -3/1  4", "0/3  1 0 1", "1  -3/1  4");
    test_add_in_place1("2  1 1/1  1", "2  -1 1/1  1", "2  0 2");
    test_add_in_place1("2  1 1/2  0 1", "2  2 1/2  -1 1", "3  -1 2 2/3  0 -1 1");
    test_add_in_place1("2  -1 1/2  2 1", "3  4 4 1/2  1 1", "4  7 12 7 1/3  2 3 1");
    test_add_in_place1("2  1 1/2  -1 1", "2  1 1", "3  0 1 1/2  -1 1");
    test_add_in_place1("1  1/2  1 1", "2  0 1/2  1 1", "1  1");
    test_add_in_place1("2  1 1/3  4 -4 1", "1  1/2  -2 1", "2  -1 2/3  4 -4 1");
    test_add_in_place1("3  0 1 1/3  1 2 1", "2  0 -1/2  1 1", "0");
    test_add_in_place1("2  1 1/2  0 1", "2  -1 1/2  0 1", "1  2");
    
    test_add_in_place2("3  1 0 1/2  0 1", "2  0 -1/3  1 0 1", "5  1 0 1 0 1/4  0 1 0 1");
    test_add_in_place2("3  -1 0 1/2  1 1", "1  2/2  -1 1", "3  3 -2 1/2  -1 1");
    test_add_in_place2("0/2  1 1", "1  2/1  1", "1  2");
    test_add_in_place2("1  -3/1  4", "0/3  1 0 1", "1  -3/1  4");
    test_add_in_place2("2  1 1/1  1", "2  -1 1/1  1", "2  0 2");
    test_add_in_place2("2  1 1/2  0 1", "2  2 1/2  -1 1", "3  -1 2 2/3  0 -1 1");
    test_add_in_place2("2  -1 1/2  2 1", "3  4 4 1/2  1 1", "4  7 12 7 1/3  2 3 1");
    test_add_in_place2("2  1 1/2  -1 1", "2  1 1", "3  0 1 1/2  -1 1");
    test_add_in_place2("1  1/2  1 1", "2  0 1/2  1 1", "1  1");
    test_add_in_place2("2  1 1/3  4 -4 1", "1  1/2  -2 1", "2  -1 2/3  4 -4 1");
    test_add_in_place2("3  0 1 1/3  1 2 1", "2  0 -1/2  1 1", "0");
    test_add_in_place2("2  1 1/2  0 1", "2  -1 1/2  0 1", "1  2");
    
    test_add_in_place3("2  1 1", "2  2 2");
    test_add_in_place3("2  1 1/1  2", "2  1 1");
    
    test_sub("3  1 0 1/2  0 1", "2  0 -1/3  1 0 1", "5  1 0 3 0 1/4  0 1 0 1");
    test_sub("3  -1 0 1/2  1 1", "1  2/2  -1 1", "3  -1 -2 1/2  -1 1");
    test_sub("0/2  1 1", "1  2/1  1", "1  -2");
    test_sub("1  -3/1  4", "0/3  1 0 1", "1  -3/1  4");
    test_sub("2  1 1/1  1", "2  -1 1/1  1", "1  2");
    test_sub("2  1 1/2  0 1", "2  2 1/2  -1 1", "2  -1 -2/3  0 -1 1");
    test_sub("2  -1 1/2  2 1", "3  4 4 1/2  1 1", "4  -9 -12 -5 -1/3  2 3 1");
    test_sub("2  -1 1/2  0 1", "1  1", "1  -1/2  0 1");
    test_sub("3  1 0 1/2  0 1", "2  0 -1/3  1 0 1", "5  1 0 3 0 1/4  0 1 0 1");
    test_sub("3  -1 0 1/2  1 1", "1  2/2  -1 1", "3  -1 -2 1/2  -1 1");
    test_sub("0/2  1 1", "1  2/1  1", "1  -2");
    test_sub("1  -3/1  4", "0/3  1 0 1", "1  -3/1  4");
    test_sub("2  1 1/1  1", "2  -1 1/1  1", "1  2");
    test_sub("2  1 1/2  0 1", "2  2 1/2  -1 1", "2  -1 -2/3  0 -1 1");
    test_sub("2  -1 1/2  2 1", "3  4 4 1/2  1 1", "4  -9 -12 -5 -1/3  2 3 1");
    test_sub("2  1 1/2  -1 1", "2  1 1", "3  2 1 -1/2  -1 1");
    test_sub("1  1/2  1 1", "2  0 1/2  1 1", "2  1 -1/2  1 1");
    test_sub("2  1 1/3  4 -4 1", "1  1/2  -2 1", "1  3/3  4 -4 1");
    test_sub("3  0 1 1/3  1 2 1", "2  0 -1/2  1 1", "2  0 2/2  1 1");
    test_sub("2  1 1/2  0 1", "2  -1 1/2  0 1", "1  2/2  0 1");
    test_sub("1  1/3  3 5 2", "1  1/3  6 7 2", "1  1/4  6 13 9 2");
    test_sub("2  1 1/2  0 2", "2  1 1/2  0 2", "0");
    test_sub("2  -1 2/2  0 1", "2  -1 1/2  0 1", "1  1");
    
    test_sub_in_place1("3  1 0 1/2  0 1", "2  0 -1/3  1 0 1", "5  1 0 3 0 1/4  0 1 0 1");
    test_sub_in_place1("3  -1 0 1/2  1 1", "1  2/2  -1 1", "3  -1 -2 1/2  -1 1");
    test_sub_in_place1("0/2  1 1", "1  2/1  1", "1  -2");
    test_sub_in_place1("1  -3/1  4", "0/3  1 0 1", "1  -3/1  4");
    test_sub_in_place1("2  1 1/1  1", "2  -1 1/1  1", "1  2");
    test_sub_in_place1("2  1 1/2  0 1", "2  2 1/2  -1 1", "2  -1 -2/3  0 -1 1");
    test_sub_in_place1("2  -1 1/2  2 1", "3  4 4 1/2  1 1", "4  -9 -12 -5 -1/3  2 3 1");
    
    test_sub_in_place2("3  1 0 1/2  0 1", "2  0 -1/3  1 0 1", "5  1 0 3 0 1/4  0 1 0 1");
    test_sub_in_place2("3  -1 0 1/2  1 1", "1  2/2  -1 1", "3  -1 -2 1/2  -1 1");
    test_sub_in_place2("0/2  1 1", "1  2/1  1", "1  -2");
    test_sub_in_place2("1  -3/1  4", "0/3  1 0 1", "1  -3/1  4");
    test_sub_in_place2("2  1 1/1  1", "2  -1 1/1  1", "1  2");
    test_sub_in_place2("2  1 1/2  0 1", "2  2 1/2  -1 1", "2  -1 -2/3  0 -1 1");
    test_sub_in_place2("2  -1 1/2  2 1", "3  4 4 1/2  1 1", "4  -9 -12 -5 -1/3  2 3 1");
    
    test_sub_in_place3("2  -1 1/2  2 1", "0");
    
    test_addmul("1  1/2  0 2", "2  3 1/1  4", "3  1 0 1/4  -2 0 0 1", "5  -4 3 1 5 1/5  0 -8 0 0 4");
    
    test_submul("1  1/2  0 2", "2  3 1/1  4", "3  1 0 1/4  -2 0 0 1", "5  -4 -3 -1 -1 -1/5  0 -8 0 0 4");
    
    /* Scalar multiplication and devision ************************************/
    
    flint_mpz_init_set_si(mpzzero, 0);
    flint_mpz_init_set_si(mpzone, 1);
    flint_mpz_init_set_si(mpztwo, 2);
    
    mpq_init(mpqzero); flint_mpq_set_si(mpqzero, 0, 1);
    mpq_init(mpqone); flint_mpq_set_si(mpqone, 1, 1);
    mpq_init(mpqtwo); flint_mpq_set_si(mpqtwo, 2, 1);
    mpq_init(mpqtwoinv); flint_mpq_set_si(mpqtwoinv, 1, 2);
    
    test_scalar_mul_si("0", 1, "0");
    test_scalar_mul_si("0", 0, "0");
    test_scalar_mul_si("1  2", 0, "0");
    test_scalar_mul_si("1  1/1  2", -2, "1  -1");
    test_scalar_mul_si("2  1 1/2  -2 3", 5, "2  5 5/2  -2 3");
    test_scalar_mul_si("2  1 1/2  -2 2", 3, "2  3 3/2  -2 2");
    
    test_scalar_mul_mpz("0", mpzone, "0");
    test_scalar_mul_mpz("0", mpzzero, "0");
    test_scalar_mul_mpz("1  2", mpzzero, "0");
    test_scalar_mul_mpz("1  1/1  2", mpztwo, "1  1");
    
    test_scalar_mul_mpq("0", mpqone, "0");
    test_scalar_mul_mpq("0", mpqzero, "0");
    test_scalar_mul_mpq("1  2", mpqzero, "0");
    test_scalar_mul_mpq("1  1/1  2", mpqtwo, "1  1");
    test_scalar_mul_mpq("1  -2/1  1", mpqtwoinv, "1  -1");
    
    test_scalar_div_si("0", 1, "0");
    test_scalar_div_si("1  2", 2, "1  1");
    test_scalar_div_si("1  1/1  2", -2, "1  -1/1  4");
    test_scalar_div_si("3  -5 0 3/2  1 1", 2, "3  -5 0 3/2  2 2");
    test_scalar_div_si("3  2 8 4/2  0 1", 3, "3  2 8 4/2  0 3");
    test_scalar_div_si("3  2 8 4/2  0 1", -3, "3  -2 -8 -4/2  0 3");
    test_scalar_div_si("3  -27 0 9/2  0 1", -3, "3  9 0 -3/2  0 1");
    
    test_scalar_div_mpz("0", mpzone, "0");
    test_scalar_div_mpz("1  2", mpztwo, "1  1");
    test_scalar_div_mpz("1  1/1  2", mpztwo, "1  1/1  4");
    
    test_scalar_div_mpq("0", mpqone, "0");
    test_scalar_div_mpq("1  2", mpqone, "1  2");
    test_scalar_div_mpq("1  1/1  2", mpqtwo, "1  1/1  4");
    test_scalar_div_mpq("1  -2/1  1", mpqtwoinv, "1  -4");
    
    mpz_clear(mpzzero);
    mpz_clear(mpzone);
    mpz_clear(mpztwo);
    mpq_clear(mpqzero);
    mpq_clear(mpqone);
    mpq_clear(mpqtwo);
    mpq_clear(mpqtwoinv);
    
    /* Multiplication, division and powing *********************************/
    
    test_mul("3  1 0 1/2  0 1", "2  0 -1/3  1 0 1", "1  -1");
    test_mul("3  -1 0 1/2  1 1", "1  2/2  -1 1", "1  2");
    test_mul("0/2  1 1", "1  2/1  1", "0");
    test_mul("1  -3/1  4", "0/3  1 0 1", "0");
    test_mul("2  1 1/1  1", "2  -1 1/1  1", "3  -1 0 1");
    test_mul("2  1 1/2  0 1", "2  2 1/2  -1 1", "3  2 3 1/3  0 -1 1");
    test_mul("2  -1 1/2  2 1", "3  4 4 1/2  1 1", "3  -2 1 1/2  1 1");
    
    test_mul_in_place1("3  1 0 1/2  0 1", "2  0 -1/3  1 0 1", "1  -1");
    test_mul_in_place1("3  -1 0 1/2  1 1", "1  2/2  -1 1", "1  2");
    test_mul_in_place1("0/2  1 1", "1  2/1  1", "0");
    test_mul_in_place1("1  -3/1  4", "0/3  1 0 1", "0");
    test_mul_in_place1("2  1 1/1  1", "2  -1 1/1  1", "3  -1 0 1");
    test_mul_in_place1("2  1 1/2  0 1", "2  2 1/2  -1 1", "3  2 3 1/3  0 -1 1");
    test_mul_in_place1("2  -1 1/2  2 1", "3  4 4 1/2  1 1", "3  -2 1 1/2  1 1");
    
    test_mul_in_place2("3  1 0 1/2  0 1", "2  0 -1/3  1 0 1", "1  -1");
    test_mul_in_place2("3  -1 0 1/2  1 1", "1  2/2  -1 1", "1  2");
    test_mul_in_place2("0/2  1 1", "1  2/1  1", "0");
    test_mul_in_place2("1  -3/1  4", "0/3  1 0 1", "0");
    test_mul_in_place2("2  1 1/1  1", "2  -1 1/1  1", "3  -1 0 1");
    test_mul_in_place2("2  1 1/2  0 1", "2  2 1/2  -1 1", "3  2 3 1/3  0 -1 1");
    test_mul_in_place2("2  -1 1/2  2 1", "3  4 4 1/2  1 1", "3  -2 1 1/2  1 1");
    
    test_mul_in_place3("2  0 1/2  1 1", "3  0 0 1/3  1 2 1");
    
    test_div("3  -1 0 1/1  2", "2  1 1/1  1", "2  -1 1/1  2");
    test_div("0/2  1 1", "2  1 1/1  1", "0");
    test_div("3  -1 0 1/1  4", "2  -1 -1/1  2", "2  1 -1/1  2");
    test_div("2  1 1", "2  1 -1/2  1 -1", "2  1 1");
    test_div("2  1 1/3  4 4 1", "2  -1 1/3  6 5 1", "3  3 4 1/3  -2 1 1");
    
    test_div_in_place1("3  -1 0 1/1  2", "2  1 1/1  1", "2  -1 1/1  2");
    test_div_in_place1("0/2  1 1", "2  1 1/1  1", "0");
    test_div_in_place1("3  -1 0 1/1  4", "2  -1 -1/1  2", "2  1 -1/1  2");
    test_div_in_place1("2  1 1", "2  1 -1/2  1 -1", "2  1 1");
    test_div_in_place1("2  1 1/3  4 4 1", "2  -1 1/3  6 5 1", "3  3 4 1/3  -2 1 1");
    test_div_in_place1("0", "1  2/2  3 5", "0");
    
    test_div_in_place2("3  -1 0 1/1  2", "2  1 1/1  1", "2  -1 1/1  2");
    test_div_in_place2("0/2  1 1", "2  1 1/1  1", "0");
    test_div_in_place2("3  -1 0 1/1  4", "2  -1 -1/1  2", "2  1 -1/1  2");
    test_div_in_place2("2  1 1", "2  1 -1/2  1 -1", "2  1 1");
    test_div_in_place2("2  1 1/3  4 4 1", "2  -1 1/3  6 5 1", "3  3 4 1/3  -2 1 1");
    
    test_div_in_place3("3  -1 0 1/1  2", "1  1");
    
    test_pow("2  0 -1/1  2", 3, "4  0 0 0 -1/1  8");
    test_pow("0", 0, "1  1");
    test_pow("2  1 -1", 0, "1  1");
    test_pow("2  1 1/2  0 1", 0, "1  1");
    
    /* Derivative ************************************************************/
    
    test_derivative("0", "0");
    test_derivative("1  2", "0");
    test_derivative("1  -1/1  2", "0");
    test_derivative("2  0 1", "1  1");
    test_derivative("3  1 0 1", "2  0 2");
    test_derivative("1  1/2  0 1", "1  -1/3  0 0 1");
    test_derivative("2  2 1/2  -1 1", "1  -3/3  1 -2 1");
    
    test_derivative("2  0 1/3  1 2 1", "2  1 -1/4  1 3 3 1");

    /* Bug which allowed constant factors */
    test_derivative("3  5 1 -2/2  10 2", "3  0 -10 -1/3  25 10 1");
    
    /* Evaluation ************************************************************/
    
    test_evaluate("1  1/1  2", -2, 3, "1/2");
    test_evaluate("3  1 0 1/2  0 1", -1, 2, "-5/2");
    test_evaluate("2  3 1/2  -1 1", 1, 1, "P");
    test_evaluate("2  3 1/2  -1 1", 2, 3, "-11");
    test_evaluate("2  3 1/2  -1 2", 1, 2, "P");
    test_evaluate("2  1 1/2  -1 1", 2, 1, "3");
    
    /* String methods ********************************************************/
    
    fmpz_poly_q_init(qpoly1);
    ans = fmpz_poly_q_set_str(qpoly1, "1  3/xyz");
    if ((ans == 0) || !fmpz_poly_q_is_zero(qpoly1))
    {
        flint_printf("test_set_str: failed\n");
        abort();
    }
    fmpz_poly_q_clear(qpoly1);
    
    fmpz_poly_q_init(qpoly1);
    ans = fmpz_poly_q_set_str(qpoly1, "abc/1  3");
    if ((ans == 0) || !fmpz_poly_q_is_zero(qpoly1))
    {
        flint_printf("test_set_str: failed\n");
        abort();
    }
    fmpz_poly_q_clear(qpoly1);
    
    fmpz_poly_q_init(qpoly1);
    ans = fmpz_poly_q_set_str(qpoly1, "abc/xyz");
    if ((ans == 0) || !fmpz_poly_q_is_zero(qpoly1))
    {
        flint_printf("test_set_str: failed\n");
        abort();
    }
    fmpz_poly_q_clear(qpoly1);
    
    test_get_str_pretty("1  -3", "-3");
    test_get_str_pretty("3  1 2 1", "t^2+2*t+1");
    test_get_str_pretty("1  -2/2  1 1", "-2/(t+1)");
    test_get_str_pretty("2  1 1/2  -1 1", "(t+1)/(t-1)");
    test_get_str_pretty("2  1 1/1  2", "(t+1)/2");
    test_get_str_pretty("1  1/1  2", "1/2");

    FLINT_TEST_CLEANUP(state);
    flint_printf("PASS\n");
    return EXIT_SUCCESS;
}
int test_if_code(int lognum) {
	int ec = true;
	int retval = true;
	uint8 op = 0;
	uint8 not_test = false;
	uint8 or_test = false;
	uint16 last_ip = ip;
	uint8 p[16] = { 0 };

	while (retval && !game.quit_prog_now) {
		if (debug_.enabled && (debug_.logic0 || lognum))
			debug_console(lognum, lTEST_MODE, NULL);

		last_ip = ip;
		op = *(code + ip++);
		memmove(p, (code + ip), 16);

		switch (op) {
		case 0xFF:	/* END IF, TEST true */
			goto end_test;
		case 0xFD:
			not_test = !not_test;
			continue;
		case 0xFC:	/* OR */
			/* if or_test is ON and we hit 0xFC, end of OR, then
			 * or is STILL false so break.
			 */
			if (or_test) {
				ec = false;
				retval = false;
				goto end_test;
			}

			or_test = true;
			continue;

		case 0x00:
			/* return true? */
			goto end_test;
		case 0x01:
			ec = test_equal(p[0], p[1]);
			if (p[0] == 11)
				timer_hack++;
			break;
		case 0x02:
			ec = test_equal(p[0], getvar(p[1]));
			if (p[0] == 11 || p[1] == 11)
				timer_hack++;
			break;
		case 0x03:
			ec = test_less(p[0], p[1]);
			if (p[0] == 11)
				timer_hack++;
			break;
		case 0x04:
			ec = test_less(p[0], getvar(p[1]));
			if (p[0] == 11 || p[1] == 11)
				timer_hack++;
			break;
		case 0x05:
			ec = test_greater(p[0], p[1]);
			if (p[0] == 11)
				timer_hack++;
			break;
		case 0x06:
			ec = test_greater(p[0], getvar(p[1]));
			if (p[0] == 11 || p[1] == 11)
				timer_hack++;
			break;
		case 0x07:
			ec = test_isset(p[0]);
			break;
		case 0x08:
			ec = test_isset(getvar(p[0]));
			break;
		case 0x09:
			ec = test_has(p[0]);
			break;
		case 0x0A:
			ec = test_obj_in_room(p[0], p[1]);
			break;
		case 0x0B:
			ec = test_posn(p[0], p[1], p[2], p[3], p[4]);
			break;
		case 0x0C:
			ec = test_controller(p[0]);
			break;
		case 0x0D:
			ec = test_keypressed();
			break;
		case 0x0E:
			ec = test_said(p[0], (uint8 *) code + (ip + 1));
			ip = last_ip;
			ip++;	/* skip opcode */
			ip += p[0] * 2;	/* skip num_words * 2 */
			ip++;	/* skip num_words opcode */
			break;
		case 0x0F:
			debugC(7, kDebugLevelScripts, "comparing [%s], [%s]", game.strings[p[0]], game.strings[p[1]]);
			ec = test_compare_strings(p[0], p[1]);
			break;
		case 0x10:
			ec = test_obj_in_box(p[0], p[1], p[2], p[3], p[4]);
			break;
		case 0x11:
			ec = test_obj_centre(p[0], p[1], p[2], p[3], p[4]);
			break;
		case 0x12:
			ec = test_obj_right(p[0], p[1], p[2], p[3], p[4]);
			break;
		default:
			ec = false;
			goto end_test;
		}

		if (op <= 0x12)
			ip += logic_names_test[op].num_args;

		/* exchange ec value */
		if (not_test)
			ec = !ec;

		/* not is only enabled for 1 test command */
		not_test = false;

		if (or_test && ec) {
			/* a true inside an OR statement passes
			 * ENTIRE statement scan for end of OR
			 */

			/* CM: test for opcode < 0xfc changed from 'op' to
			 *     '*(code+ip)', to avoid problem with the 0xfd (NOT)
			 *     opcode byte. Changed a bad ip += ... ip++ construct.
			 *     This should fix the crash with Larry's logic.0 code:
			 *
			 *     if ((isset(4) ||
			 *          !isset(2) ||
			 *          v30 == 2 ||
			 *          v30 == 1)) {
			 *       goto Label1;
			 *     }
			 *
			 *     The bytecode is: 
			 *     ff fc 07 04 fd 07 02 01 1e 02 01 1e 01 fc ff
			 */

			/* find end of OR */
			while (*(code + ip) != 0xFC) {
				if (*(code + ip) == 0x0E) {	/* said */
					ip++;
					/* cover count + ^words */
					ip += 1 + ((*(code + ip)) * 2);
					continue;
				}

				if (*(code + ip) < 0xFC)
					ip += logic_names_test[*(code + ip)].num_args;
				ip++;
			}
			ip++;

			or_test = false;
			retval = true;
		} else {
			retval = or_test ? retval || ec : retval && ec;
		}
	}
      end_test:

	/* if false, scan for end of IP? */
	if (retval)
		ip += 2;
	else {
		ip = last_ip;
		while (*(code + ip) != 0xff) {
			if (*(code + ip) == 0x0e) {
				ip++;
				ip += (*(code + ip)) * 2 + 1;
			} else if (*(code + ip) < 0xfc) {
				ip += logic_names_test[*(code + ip)].num_args;
				ip++;
			} else {
				ip++;
			}
		}
		ip++;		/* skip over 0xFF */
		ip += READ_LE_UINT16(code + ip) + 2;
	}

	if (debug_.enabled && (debug_.logic0 || lognum))
		debug_console(lognum, 0xFF, retval ? "=true" : "=false");

	return retval;
}
Exemple #25
0
void test_all_equal() {
    test_equal(nan, nan, one, "nan = nan");
    test_equal(nan, zero, zero, "nan = zero");
    test_equal(nan, nannan, one, "nan = nannan");
    test_equal(nannan, nannan, one, "nannan = nannan");
    test_equal(nannan, nan, one, "nannan = nan");
    test_equal(nannan, one, zero, "nannan = 1");
    test_equal(zero, nan, zero, "zero = nan");
    test_equal(zero, nannan, zero, "0 = nannan");
    test_equal(zero, zip, one, "zero = zip");
    test_equal(zero, minnum, zero, "zero = minnum");
    test_equal(zero, one, zero, "zero = one");
    test_equal(zip, zero, one, "zip = zero");
    test_equal(zip, zip, one, "zip = zip");
    test_equal(one, negative_one, zero, "1 = -1");
    test_equal(two, two, one, "2 = 2");
    test_equal(two, dec64_new(2, -16), zero, "2 = 2e-16");
    test_equal(pi, three, zero, "pi = 3");
    test_equal(maxint, maxnum, zero, "maxint = maxnum");
    test_equal(negative_maxint, maxint, zero, "-maxint = maxint");
    test_equal(negative_maxint, negative_one, zero, "-maxint = -1");
}