Esempio n. 1
0
SemVal *p_addition(SemVal *lval, SemVal *rval)
{
    register ExprType type;

    if (p_testBinOp(op_add, lval, rval))
        return p_nullFrame(lval, rval);     /* test for correct types */

    p_bool2int(lval);                       /* convert pending booleans */
    p_bool2int(rval);

    if (p_conflict(lval, rval, op_add))     /* test type p_conflict */
        return p_nullFrame(lval, rval);

    type = lval->type;                      /* keep type for later */

    if ((type & rval->type & (unsigned)~e_typeMask) == e_const)
    {
        if (test_type(lval, e_int))
            lval->evalue += rval->evalue;
        else if (test_type(lval, e_str))
            p_catStrings(lval, rval);         /* create (cat) new string */
    }
    else 
    {
        p_binOp(lval, rval, op_add);
        set_type(lval, (type & e_typeMask) | e_stack);
    }

    return lval;                            /* return new expression */
}
    void t5()
    {
        //
        // Now integer functions:
        //
        ref_type z1, z2;
        test_type t1, t2;
        divide_qr(a, b, z1, z2);
        divide_qr(a1, b1, t1, t2);
        BOOST_TEST_EQ(z1.str(), t1.str());
        BOOST_TEST_EQ(z2.str(), t2.str());
        BOOST_TEST_EQ(integer_modulus(a, si), integer_modulus(a1, si));
        BOOST_TEST_EQ(lsb(a), lsb(a1));

        for(unsigned i = 0; i < 1000; i += 13)
        {
            BOOST_TEST_EQ(bit_test(a, i), bit_test(a1, i));
        }
        // We have to take care that our powers don't grow too large, otherwise this takes "forever",
        // also don't test for modulo types, as these may give a different result from arbitrary
        // precision types:
        BOOST_TEST_EQ(ref_type(pow(d, ui % 19)).str(), test_type(pow(d1, ui % 19)).str());
        BOOST_TEST_EQ(ref_type(powm(a, b, c)).str(), test_type(powm(a1, b1, c1)).str());
        BOOST_TEST_EQ(ref_type(powm(a, b, ui)).str(), test_type(powm(a1, b1, ui)).str());
        BOOST_TEST_EQ(ref_type(powm(a, ui, c)).str(), test_type(powm(a1, ui, c1)).str());
    }
Esempio n. 3
0
	virtual void* run()
	{
		bool ret;
		acl::redis_client* conn;
		acl::redis_key redis;

		for (int i = 0; i < n_; i++)
		{
			conn = (acl::redis_client*) pool_.peek();
			
			if (conn == NULL)
			{
				printf("peek redis_client failed\r\n");
				break;
			}

			redis.set_client(conn);

			if (cmd_ == "del")
				ret = test_del(redis, i);
			else if (cmd_ == "expire")
				ret = test_expire(redis, i);
			else if (cmd_ == "ttl")
				ret = test_ttl(redis, i);
			else if (cmd_ == "exists")
				ret = test_exists(redis, i);
			else if (cmd_ == "type")
				ret = test_type(redis, i);
			else if (cmd_ == "all")
			{
				if (test_expire(redis, i) == false
					|| test_ttl(redis, i) == false
					|| test_exists(redis, i) == false
					|| test_type(redis, i) == false
					|| test_del(redis, i) == false)
				{
					ret = false;
				}
				else
					ret = true;
			}
			else
			{
				printf("unknown cmd: %s\r\n", cmd_.c_str());
				break;
			}
			pool_.put(conn, ret);
			if (ret == false)
				break;
		}

		return NULL;
	}
Esempio n. 4
0
SemVal *p_greater(SemVal *lval, SemVal *rval)
{
    p_bool2int(lval);                             /* convert boolean to i */
    p_bool2int(rval);

    if (p_conflict(lval, rval, op_gr))        /* test type p_conflict */
        return(lval);

    if ((lval->type & rval->type & (size_t)~e_typeMask) == e_const)
    {
        if (test_type(lval, e_int))
            lval->evalue = (lval->evalue > rval->evalue);
        else
        {
            lval->evalue =
                      (
                        strcmp
                        (
                            gp_stringTable[lval->evalue].string,
                            gp_stringTable[rval->evalue].string
                        )
                      ) > 0;
            set_type(lval, e_int | e_const);
        }
    }
    else
        p_binOp(lval, rval, op_gr);

    return (lval);                          /* return new expression */
}
Esempio n. 5
0
static void test_basic_set(Generator *gen) {
        uint32_t i, j, n;
        char c, *s;

        printf("Test standard set of 8k variants..\n");

        for (i = 0; i < 8192; ++i) {
                generator_seed_u32(gen, i);
                generator_reset(gen);

                j = 0;
                n = 0;
                s = NULL;

                do {
                        c = generator_step(gen);
                        if (j >= n) {
                                n = n ? (n * 2) : 128;
                                s = realloc(s, n);
                                assert(s);
                        }
                        s[j++] = c;
                } while (c);

                printf("  %u: %s\n", i, s);
                test_type(s);
                free(s);
        }
}
Esempio n. 6
0
int main(int argc, char** argv)
{
	printf("KEY META     TESTS\n");
	printf("==================\n\n");

	init (argc, argv);
	test_basic();
	test_iterate();
	test_size();
	test_uid();
	test_dup();
	test_comment();
	test_owner();
	test_mode();
	test_type();
	test_examples();
	test_copy();
	test_ro();
	test_new();
	test_copyall();


	printf("\ntest_ks RESULTS: %d test(s) done. %d error(s).\n", nbTest, nbError);

	return nbError;
}
Esempio n. 7
0
SemVal *p_smEqual(SemVal *lval, SemVal *rval)
{
    p_bool2int(lval);                           /* convert boolean to i */
    p_bool2int(rval);

    if (p_conflict(lval, rval, op_smeq))        /* test type p_conflict */
        return p_nullFrame(lval, rval);

    if ((lval->type & rval->type & (unsigned)~e_typeMask) == e_const)
    {
        if (test_type(lval, e_int))
            lval->evalue = (lval->evalue <= rval->evalue);
        else
        {
            lval->evalue =
                      (
                        strcmp
                        (
                            gp_stringTable[lval->evalue].string,
                            gp_stringTable[rval->evalue].string
                        )
                      ) <= 0;
            set_type(lval, e_int | e_const);
        }
    }
    else
        p_binOp(lval, rval, op_smeq);

    return lval;                            /* return new expression */
}
Esempio n. 8
0
ESTRUC_ *gr_equal (ESTRUC_ *lval, ESTRUC_ *rval)
{
    btoi(lval);                             /* convert boolean to i */
    btoi(rval);

    if (conflict(lval, rval, op_greq))      /* test type conflict */
        return(lval);

    if ((lval->type & rval->type & (size_t)~ALLTYPES) == e_const)
    {
        if (test_type(lval, e_int))
            lval->evalue = (lval->evalue >= rval->evalue);
        else
        {
            lval->evalue =
                      (
                        strcmp
                        (
                            stringtab[lval->evalue].string,
                            stringtab[rval->evalue].string
                        )
                      ) >= 0;
            set_type(lval, e_int | e_const);
        }
    }
    else
        defcode(lval, rval, op_greq);

    return (lval);                          /* return new expression */
}
Esempio n. 9
0
int main(void)
{
	bool ret = true;

	talloc_disable_null_tracking();
	talloc_enable_null_tracking();

	ret &= test_ref1();
	ret &= test_ref2();
	ret &= test_ref3();
	ret &= test_ref4();
	ret &= test_unlink1(); 
	ret &= test_misc();
	ret &= test_realloc();
	ret &= test_realloc_child(); 
	ret &= test_steal(); 
	ret &= test_move(); 
	ret &= test_unref_reparent();
	ret &= test_realloc_fn(); 
	ret &= test_type();
	ret &= test_lifeless(); 
	ret &= test_loop();
	ret &= test_free_parent_deny_child(); 
	ret &= test_talloc_ptrtype();

	if (ret) {
		ret &= test_speed();
	}
	ret &= test_autofree();

	if (!ret)
		return -1;
	return 0;
}
Esempio n. 10
0
void DynamicRawFeature::upgrade_feature_type(const char * value)
{
    // This ascertains that the value is a number
    parse_string<float>(value);
    
    // Find a suitable type for the feature
    int current_type_level = static_cast<int>(this->type);
    int potential_type = current_type_level + 1;
    while (potential_type <= static_cast<int>(MAX_RAW_FEATURE_TYPE) ) {
        try {
            std::unique_ptr<ColumnConsumer> test_type(this->create_raw_feature_for_type(static_cast<RawFeatureType>(potential_type)));
            test_type->consume_cell(value);
            test_type->consume_cell(this->feature->get_min_str().c_str());
            test_type->consume_cell(this->feature->get_max_str().c_str());
            break;
        } catch (number_format_error& e) {
            (void)e;
            potential_type++;
        } 
    }
    if (potential_type > static_cast<int>(MAX_RAW_FEATURE_TYPE)) {
        throw std::runtime_error(std::string("Cannot parse value in tsv file as number: ") + value);
    }
    RawFeatureType new_feature_type = static_cast<RawFeatureType>(potential_type);
    
    // Convert the feature
    std::unique_ptr<AbstractRawFeature> new_feature(this->create_raw_feature_for_type(new_feature_type));
    new_feature->import_data(this->feature->export_data().get());
    this->feature = std::move(new_feature);
}
Esempio n. 11
0
static void test_specific_type(Generator *gen, const char *input) {
        uint32_t j, n;
        char c, *s;

        if (!input[strspn(input, "0123456789")]) {
                generator_seed_str(gen, input, 10);
                generator_reset(gen);

                j = 0;
                n = 0;
                s = NULL;

                do {
                        c = generator_step(gen);
                        if (j >= n) {
                                n = n ? (n * 2) : 128;
                                s = realloc(s, n);
                                assert(s);
                        }
                        s[j++] = c;
                } while (c);
        } else {
                s = strdup(input);
                assert(s);
        }

        printf("Test '%s'..\n", s);

        test_type(s);
        free(s);
}
Esempio n. 12
0
InputParameters validParams<TestPostprocessor>()
{
  InputParameters params = validParams<GeneralPostprocessor>();
  MooseEnum test_type("grow use_older_value report_old");
  params.addRequiredParam<MooseEnum>("test_type", test_type, "The type of test to perform");
  params.addParam<PostprocessorName>("report_name", "The name of the postprocessor value to report");
  return params;
}
Esempio n. 13
0
void test_misc(Ardb& db)
{
    test_type(db);
    test_sort_list(db);
    test_sort_set(db);
    test_sort_zset(db);
    test_keys(db);
}
Esempio n. 14
0
int p_testOperand(SemVal *e, Opcode opcode)
{
    register int ret;

    if ( (ret = !test_type(e, gp_opType[opcode])) )
        util_semantic(gp_illegalType, gp_opstring[opcode]);

    return ret;
}
Esempio n. 15
0
SemVal *p_indexOp(SemVal *larg, SemVal *rarg)
{
    register int ok;
    ExprType type = f_element;
    SemVal *tmp;


    p_expr2stack(larg);                             /* arg to stack */
    p_expr2stack(rarg);                             /* arg to stack */

    /* This follows the code of `p_twoArgs.c' to compute a list/string    */
    /* element                                                          */

                                            /* first arg must be int */
    if (!test_type(larg, e_int))            /* first expression is no int */
    {
        tmp = larg;                         /* then swap    */
        larg = rarg;
        rarg = tmp;
    }

    if ( (ok = test_type(larg, e_int)) )    /* right arg must be int    */
    {                               /* second arg == list: ok */
        if (!(ok = test_type(rarg, e_list)))
        {                           /* second arg == string: ok */
            ok = test_type(rarg, e_str);
            type = f_str_el;        /* string element requested */
        }
    }

    if (ok)
    {
        p_catCode(rarg, larg);                /* make one code vector */
        p_callRss(rarg, type);
    }
    else
    {
        util_semantic(gp_typeConflict, gp_funstring[type]);
        p_discard(larg);
    }
    return (rarg);
}
Esempio n. 16
0
/*
 * TEST1 : all base types
 */
static void test_base_types(void) {
  uint32_t i;

  printf("*****************\n"
	 "*   BASE TYPES  *\n"
	 "*****************\n"
	 "\n");

  for (i=0; i<NUM_BASE_TYPES; i++) {
    test_type(base[i], 100);
  }
}
Esempio n. 17
0
TEST(function, sum)
{
    {
        test_type sum;
        weos::function<test_type()> f
            = weos::bind<test_type>(&sum4, 1, 2, 3, 4);
        sum = f();
        ASSERT_EQ(10, sum);
        weos::function<test_type()> g(f);
        sum = g();
        ASSERT_EQ(10, sum);
        weos::function<test_type()> h;
        h = f;
        sum = h();
        ASSERT_EQ(10, sum);
    }
    {
        test_type sum;
        weos::function<test_type(test_type)> f
            = weos::bind<test_type>(&sum4, weos::placeholders::_1, 2, 3, 4);
        sum = f(1);
        ASSERT_EQ(10, sum);
        weos::function<test_type(test_type)> g(f);
        sum = g(2);
        ASSERT_EQ(11, sum);
        weos::function<test_type(test_type)> h;
        h = f;
        sum = h(3);
        ASSERT_EQ(12, sum);
    }
}
Esempio n. 18
0
File: lbind.c Progetto: ifzz/nui
static int Lisa(lua_State *L) {
  lbind_Type *t = test_type(L, 1);
  int i, top = lua_gettop(L);
  if (t == NULL)
    lbind_typeerror(L, 1, "lbind object/type");
  for (i = 2; i <= top; ++i) {
    if (!lbind_isa(L, i, t)) {
      lua_pushnil(L);
      lua_replace(L, i);
    }
  }
  return top - 1;
}
Esempio n. 19
0
File: lbind.c Progetto: ifzz/nui
static int Ltype(lua_State *L) {
  int i, top = lua_gettop(L);
  if (top == 0) {
    get_typebox(L);
    return 1;
  }
  for (i = 1; i <= top; ++i) {
    lbind_Type *t = test_type(L, i);
    lua_pushstring(L, t != NULL ? t->name : luaL_typename(L, -1));
    lua_replace(L, i);
  }
  return top;
}
 void t2()
 {
     // bitwise ops:
     BOOST_TEST_EQ(ref_type(a|b).str(), test_type(a1 | b1).str());
     BOOST_TEST_EQ((ref_type(a)|=b).str(), (test_type(a1) |= b1).str());
     BOOST_TEST_EQ(ref_type(a&b).str(), test_type(a1 & b1).str());
     BOOST_TEST_EQ((ref_type(a)&=b).str(), (test_type(a1) &= b1).str());
     BOOST_TEST_EQ(ref_type(a^b).str(), test_type(a1 ^ b1).str());
     BOOST_TEST_EQ((ref_type(a)^=b).str(), (test_type(a1) ^= b1).str());
     // Shift ops:
     for (unsigned i = 0; i < 128; ++i)
     {
         BOOST_TEST_EQ(ref_type(a << i).str(), test_type(a1 << i).str());
         BOOST_TEST_EQ(ref_type(a >> i).str(), test_type(a1 >> i).str());
     }
     // gcd/lcm
     BOOST_TEST_EQ(ref_type(gcd(a, b)).str(), test_type(gcd(a1, b1)).str());
     BOOST_TEST_EQ(ref_type(lcm(c, d)).str(), test_type(lcm(c1, d1)).str());
 }
Esempio n. 21
0
int main()
{
  test_type(chaiscript::user_type<void>(), false, false, false, true, false);
  test_type(chaiscript::user_type<const int>(), true, false, false, false, false);
  test_type(chaiscript::user_type<const int &>(), true, false, true, false, false);
  test_type(chaiscript::user_type<int>(), false, false, false, false, false);
  test_type(chaiscript::user_type<int *>(), false, true, false, false, false);
  test_type(chaiscript::user_type<const int *>(), true, true, false, false, false);
  test_type(chaiscript::Type_Info(), false, false, false, false, true);

  return EXIT_SUCCESS;
}
InputParameters
validParams<GetMaterialPropertyBoundaryBlockNamesTest>()
{
  InputParameters params = validParams<GeneralUserObject>();
  params.addRequiredParam<std::string>("property_name",
                                       "The name of the property to extract boundary names for");
  params.addRequiredParam<std::vector<std::string>>(
      "expected_names", "The names expected to be returned by getMaterialPropertyBoundaryNames()");
  MooseEnum test_type("block boundary");
  params.addRequiredParam<MooseEnum>(
      "test_type", test_type, "The type of test to execute (block | boundary)");

  return params;
}
Esempio n. 23
0
int main(int argc, char *argv[])
{
	plan_tests(5);
	failtest_init(argc, argv);

	talloc_enable_null_tracking();
	if (null_context) {
		ok1(test_type(NULL));
		/* This closes the leak, but don't free any other leaks! */
		ok1(!talloc_chunk_from_ptr(null_context)->child);
		talloc_disable_null_tracking();
	}
	failtest_exit(exit_status());
}
Esempio n. 24
0
File: lbind.c Progetto: ifzz/nui
static int Lcastto(lua_State *L) {
  lbind_Type *t = test_type(L, 1);
  int i, top = lua_gettop(L);
  if (t == NULL)
    lbind_typeerror(L, 1, "lbind object/type");
  for (i = 2; i <= top; ++i) {
    void *u = lbind_cast(L, -2, t);
    if (u == NULL)
      lua_pushnil(L);
    else if (!lbind_retrieve(L, u))
      lbind_wrap(L, u, t);
    lua_replace(L, i);
  }
  return top - 1;
}
Esempio n. 25
0
SemVal *p_orBool(SemVal *lexp, SemVal *rexp)
{
    if (lexp->type & rexp->type & e_const)  /* two constants: compute result */
    {
        lexp->evalue =
            (test_type(lexp, e_str) || lexp->evalue)
            ||
            (test_type(rexp, e_str) || rexp->evalue);
        set_type(lexp, e_const | e_int);
    }
    else                                    /* at least one code-part */
    {
        p_forceExpr2Bool(lexp);                        /* boolean code */
        p_forceExpr2Bool(rexp);

        lexp->codelen -= p_rmJmpZero(lexp->codelen, lexp->falselist,
                                    lexp->falselen);
        p_patchupFalse(lexp, 1);
        lexp = p_catCode(lexp, rexp);
        set_type(lexp, e_bool | e_stack);
    }

    return (lexp);
}
Esempio n. 26
0
SemVal *p_optIntSpecial(ExprType type, SemVal *larg, SemVal *rarg)
{
    SemVal tmp;

    p_expr2stack(larg);                             /* arg to stack */

    if (!test_type(larg, e_int))            /* no first int arg */
    {                                       /* prefix the first argument */
        rarg = p_insertArg(larg, rarg);
                                            /* make 0-argument */
        tmp = *p_stackFrame(e_int | e_const);
        larg = &tmp;                        /* larg points to inserted arg */
    }

    return p_specials(type, p_insertArg(larg, rarg));
}
Esempio n. 27
0
InputParameters
validParams<TestControl>()
{
  InputParameters params = validParams<Control>();

  MooseEnum test_type(
      "real variable point tid_warehouse_error disable_executioner connection alias mult");
  params.addRequiredParam<MooseEnum>(
      "test_type", test_type, "Indicates the type of test to perform");
  params.addParam<std::string>(
      "parameter",
      "The input parameter(s) to control. Specify a single parameter name and all "
      "parameters in all objects matching the name will be updated");

  return params;
}
Esempio n. 28
0
static bool test(const char* in, bool once, const char* name)
{
	acl::json json;
	const char* ptr = NULL, *p1 = in;
	char  buf[2];
       
	if (once)
		ptr = json.update(p1);
	else
	{
		while (*p1)
		{
			buf[0] = *p1;
			buf[1] = 0;
			ptr = json.update(buf);
			p1++;
		}
	}

	printf("------------------  input json ------------------------\r\n");
	printf("%s\r\n", in);
	printf("-------------------------------------------------------\r\n");

	printf("json finish: %s, left: |%s|, len: %d\r\n",
		json.finish() ? "yes" : "no", ptr, (int) strlen(ptr));

	printf("------------------ rebuild json -----------------------\r\n");
	printf("%s\r\n", json.to_string().c_str());
	printf("-------------------------------------------------------\r\n");

	acl::string ibuf(in);
	ibuf.trim_space().trim_right_line();

	acl::string obuf = json.to_string();
	obuf.trim_space();

	if (ibuf == obuf)
		printf("\r\n-----OK----\r\n\r\n");
	else
		printf("\r\n-----Error----\r\n\r\n");

	if (name && *name)
		test_type(json, name);

	return true;
}
Esempio n. 29
0
void p_bool2int(SemVal *e)
{
    if (!test_type(e, e_bool))              /* no batchpatching needed */
        return;

    p_patchupTrue(e, 1);
    e->truelen = 0;

    p_generateCode(e, op_push_1_jmp_end);          /* truelist target */

    p_patchupFalse(e, 1);
    e->falselen = 0;

    p_generateCode(e, op_push_0);                  /* falselist target */

    set_type(e, e_int | e_stack);            /* set int code type */
}
Esempio n. 30
0
/* Calculates the truth value of the next condition starting from
   p. Returns the point after condition. */
static char *test_condition (char *p, int *condition)
{
    WPanel *panel;
    char arg [256];

    /* Handle one condition */
    for (;*p != '\n' && *p != '&' && *p != '|'; p++){
    if (*p == ' ' || *p == '\t')
        continue;
    if (*p >= 'a')
        panel = cpanel;
    else {
        if (get_other_type () == view_listing)
        panel = other_panel;
        else
        panel = NULL;
    }
    *p |= 0x20;

    switch (*p++){
    case '!':
        p = test_condition (p, condition);
        *condition = ! *condition;
        p--;
        break;
    case 'f':
        p = extract_arg (p, arg);
        *condition = panel && regexp_match (arg, panel->dir.list [panel->selected].fname, match_file);
        break;
    case 'd':
        p = extract_arg (p, arg);
        *condition = panel && regexp_match (arg, panel->cwd, match_file);
        break;
    case 't':
        p = extract_arg (p, arg);
        *condition = panel && test_type (panel, arg);
        break;
    default:
        debug_error = 1;
        break;
    } /* switch */

    } /* while */
    return p;
}