本文整理汇总了C++中Branch::eval方法的典型用法代码示例。如果您正苦于以下问题:C++ Branch::eval方法的具体用法?C++ Branch::eval怎么用?C++ Branch::eval使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Branch
的用法示例。
在下文中一共展示了Branch::eval方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: repro_source_after_append_code
void repro_source_after_append_code()
{
Branch branch;
Term* target = branch.compile("target = {}");
branch.eval("bm = branch_ref(target)");
branch.eval("bm.append_code({ 1 + 1 })");
test_equals(get_branch_source_text(nested_contents(target)), " 1 + 1 ");
}
示例2: test_if_joining_on_bool
void test_if_joining_on_bool()
{
// The following code once had a bug where cond wouldn't work
// if one of its inputs was missing value.
Branch branch;
caValue* s = branch.eval("hey = true");
test_assert(s->value_data.ptr != NULL);
branch.eval("if false { hey = false }");
evaluate_branch(&branch);
test_assert(branch["hey"]->asBool() == true);
}
示例3: test_if_joining
void test_if_joining()
{
Branch branch;
// Test that a name defined in one branch is not rebound in outer scope
branch.eval("if true { apple = 5 }");
test_assert(!branch.contains("apple"));
// Test that a name which exists in the outer scope is rebound
Term* original_banana = create_int(&branch, 10, "banana");
branch.eval("if true { banana = 15 }");
test_assert(branch["banana"] != original_banana);
// Test that if a name is defined in both 'if' and 'else' branches, that it gets
// defined in the outer scope.
branch.eval("if true { Cardiff = 5 } else { Cardiff = 11 }");
test_assert(branch.contains("Cardiff"));
// Test that the type of the joined name is correct
branch.compile("if true { a = 4 } else { a = 5 }; a = a");
test_equals(get_output_type(branch["a"])->name, "int");
}