Merge pull request #1 from dpogue/master
Improved tests and support PRINT_*_TO
This commit is contained in:
@@ -319,13 +319,15 @@ private:
|
||||
|
||||
class ASTPrint : public ASTNode {
|
||||
public:
|
||||
ASTPrint(PycRef<ASTNode> value)
|
||||
: ASTNode(NODE_PRINT), m_value(value) { }
|
||||
ASTPrint(PycRef<ASTNode> value, PycRef<ASTNode> stream = Node_NULL)
|
||||
: ASTNode(NODE_PRINT), m_value(value), m_stream(stream) { }
|
||||
|
||||
PycRef<ASTNode> value() const { return m_value; }
|
||||
PycRef<ASTNode> stream() const { return m_stream; }
|
||||
|
||||
private:
|
||||
PycRef<ASTNode> m_value;
|
||||
PycRef<ASTNode> m_stream;
|
||||
};
|
||||
|
||||
|
||||
|
29
ASTree.cpp
29
ASTree.cpp
@@ -753,7 +753,9 @@ PycRef<ASTNode> BuildFromCode(PycRef<PycCode> code, PycModule* mod)
|
||||
if (!curblock->inited()) {
|
||||
curblock.cast<ASTCondBlock>()->init();
|
||||
break;
|
||||
} else if (value->type() == ASTNode::NODE_INVALID) {
|
||||
} else if (value->type() == ASTNode::NODE_INVALID
|
||||
|| value->type() == ASTNode::NODE_BINARY
|
||||
|| value->type() == ASTNode::NODE_NAME) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -764,9 +766,22 @@ PycRef<ASTNode> BuildFromCode(PycRef<PycCode> code, PycModule* mod)
|
||||
curblock->append(new ASTPrint(stack.top()));
|
||||
stack.pop();
|
||||
break;
|
||||
case Pyc::PRINT_ITEM_TO:
|
||||
{
|
||||
PycRef<ASTNode> stream = stack.top();
|
||||
stack.pop();
|
||||
|
||||
curblock->append(new ASTPrint(stack.top(), stream));
|
||||
stack.pop();
|
||||
break;
|
||||
}
|
||||
case Pyc::PRINT_NEWLINE:
|
||||
curblock->append(new ASTPrint(Node_NULL));
|
||||
break;
|
||||
case Pyc::PRINT_NEWLINE_TO:
|
||||
curblock->append(new ASTPrint(Node_NULL, stack.top()));
|
||||
stack.pop();
|
||||
break;
|
||||
case Pyc::RAISE_VARARGS_A:
|
||||
{
|
||||
ASTRaise::param_t paramList;
|
||||
@@ -1430,9 +1445,21 @@ void print_src(PycRef<ASTNode> node, PycModule* mod)
|
||||
break;
|
||||
case ASTNode::NODE_PRINT:
|
||||
if (node.cast<ASTPrint>()->value() == Node_NULL) {
|
||||
if (!inPrint) {
|
||||
printf("print ");
|
||||
if (node.cast<ASTPrint>()->stream() != Node_NULL) {
|
||||
printf(">>");
|
||||
print_src(node.cast<ASTPrint>()->stream(), mod);
|
||||
}
|
||||
}
|
||||
inPrint = false;
|
||||
} else if (!inPrint) {
|
||||
printf("print ");
|
||||
if (node.cast<ASTPrint>()->stream() != Node_NULL) {
|
||||
printf(">>");
|
||||
print_src(node.cast<ASTPrint>()->stream(), mod);
|
||||
printf(", ");
|
||||
}
|
||||
print_src(node.cast<ASTPrint>()->value(), mod);
|
||||
inPrint = true;
|
||||
} else {
|
||||
|
4
Makefile
4
Makefile
@@ -52,10 +52,10 @@ test: all
|
||||
do \
|
||||
stderr=$$( ./bin/pycdc "$$f" 2>&1 1>/dev/null ); \
|
||||
if [ "$$?" -eq "0" -a -z "$$stderr" ]; then \
|
||||
echo "\033[32mPASSED\033[m $$f"; \
|
||||
echo -e "\033[32mPASSED\033[m $$f"; \
|
||||
else \
|
||||
echo $$stderr; \
|
||||
echo "\033[31mFAILED\033[m $$f"; \
|
||||
echo -e "\033[31mFAILED\033[m $$f"; \
|
||||
fi \
|
||||
done;
|
||||
|
||||
|
BIN
tests/15_test_class.pyc
Normal file
BIN
tests/15_test_class.pyc
Normal file
Binary file not shown.
BIN
tests/15_test_del.pyc
Normal file
BIN
tests/15_test_del.pyc
Normal file
Binary file not shown.
BIN
tests/15_test_docstring.pyc
Normal file
BIN
tests/15_test_docstring.pyc
Normal file
Binary file not shown.
BIN
tests/15_test_empty.pyc
Normal file
BIN
tests/15_test_empty.pyc
Normal file
Binary file not shown.
BIN
tests/15_test_exceptions.pyc
Normal file
BIN
tests/15_test_exceptions.pyc
Normal file
Binary file not shown.
BIN
tests/15_test_exec.pyc
Normal file
BIN
tests/15_test_exec.pyc
Normal file
Binary file not shown.
BIN
tests/15_test_expressions.pyc
Normal file
BIN
tests/15_test_expressions.pyc
Normal file
Binary file not shown.
BIN
tests/15_test_functions.pyc
Normal file
BIN
tests/15_test_functions.pyc
Normal file
Binary file not shown.
BIN
tests/15_test_global.pyc
Normal file
BIN
tests/15_test_global.pyc
Normal file
Binary file not shown.
BIN
tests/15_test_globals.pyc
Normal file
BIN
tests/15_test_globals.pyc
Normal file
Binary file not shown.
BIN
tests/15_test_import.pyc
Normal file
BIN
tests/15_test_import.pyc
Normal file
Binary file not shown.
BIN
tests/15_test_integers.pyc
Normal file
BIN
tests/15_test_integers.pyc
Normal file
Binary file not shown.
BIN
tests/15_test_lambda.pyc
Normal file
BIN
tests/15_test_lambda.pyc
Normal file
Binary file not shown.
BIN
tests/15_test_loops.pyc
Normal file
BIN
tests/15_test_loops.pyc
Normal file
Binary file not shown.
BIN
tests/15_test_misc.pyc
Normal file
BIN
tests/15_test_misc.pyc
Normal file
Binary file not shown.
BIN
tests/15_test_prettyprint.pyc
Normal file
BIN
tests/15_test_prettyprint.pyc
Normal file
Binary file not shown.
BIN
tests/15_test_print.pyc
Normal file
BIN
tests/15_test_print.pyc
Normal file
Binary file not shown.
BIN
tests/15_test_single_stmt.pyc
Normal file
BIN
tests/15_test_single_stmt.pyc
Normal file
Binary file not shown.
BIN
tests/15_test_slices.pyc
Normal file
BIN
tests/15_test_slices.pyc
Normal file
Binary file not shown.
BIN
tests/15_test_tuple_params.pyc
Normal file
BIN
tests/15_test_tuple_params.pyc
Normal file
Binary file not shown.
BIN
tests/15_test_tuples.pyc
Normal file
BIN
tests/15_test_tuples.pyc
Normal file
Binary file not shown.
BIN
tests/15_tuple_params.pyc
Normal file
BIN
tests/15_tuple_params.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_applyEquiv.pyc
Normal file
BIN
tests/22_test_applyEquiv.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_augmentedAssign.pyc
Normal file
BIN
tests/22_test_augmentedAssign.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_class.pyc
Normal file
BIN
tests/22_test_class.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_del.pyc
Normal file
BIN
tests/22_test_del.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_divide_future.pyc
Normal file
BIN
tests/22_test_divide_future.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_divide_no_future.pyc
Normal file
BIN
tests/22_test_divide_no_future.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_docstring.pyc
Normal file
BIN
tests/22_test_docstring.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_empty.pyc
Normal file
BIN
tests/22_test_empty.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_exceptions.pyc
Normal file
BIN
tests/22_test_exceptions.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_exec.pyc
Normal file
BIN
tests/22_test_exec.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_expressions.pyc
Normal file
BIN
tests/22_test_expressions.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_extendedImport.pyc
Normal file
BIN
tests/22_test_extendedImport.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_extendedPrint.pyc
Normal file
BIN
tests/22_test_extendedPrint.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_functions.pyc
Normal file
BIN
tests/22_test_functions.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_global.pyc
Normal file
BIN
tests/22_test_global.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_globals.pyc
Normal file
BIN
tests/22_test_globals.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_import.pyc
Normal file
BIN
tests/22_test_import.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_import_as.pyc
Normal file
BIN
tests/22_test_import_as.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_iterators.pyc
Normal file
BIN
tests/22_test_iterators.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_lambda.pyc
Normal file
BIN
tests/22_test_lambda.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_listComprehensions.pyc
Normal file
BIN
tests/22_test_listComprehensions.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_loops.pyc
Normal file
BIN
tests/22_test_loops.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_loops2.pyc
Normal file
BIN
tests/22_test_loops2.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_misc.pyc
Normal file
BIN
tests/22_test_misc.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_nested_elif.pyc
Normal file
BIN
tests/22_test_nested_elif.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_nested_scopes.pyc
Normal file
BIN
tests/22_test_nested_scopes.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_prettyprint.pyc
Normal file
BIN
tests/22_test_prettyprint.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_print.pyc
Normal file
BIN
tests/22_test_print.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_print_to.pyc
Normal file
BIN
tests/22_test_print_to.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_single_stmt.pyc
Normal file
BIN
tests/22_test_single_stmt.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_slices.pyc
Normal file
BIN
tests/22_test_slices.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_tuple_params.pyc
Normal file
BIN
tests/22_test_tuple_params.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_tuples.pyc
Normal file
BIN
tests/22_test_tuples.pyc
Normal file
Binary file not shown.
BIN
tests/22_test_yield.pyc
Normal file
BIN
tests/22_test_yield.pyc
Normal file
Binary file not shown.
BIN
tests/22_z_test_integers.pyc
Normal file
BIN
tests/22_z_test_integers.pyc
Normal file
Binary file not shown.
BIN
tests/27_print_to.pyc
Normal file
BIN
tests/27_print_to.pyc
Normal file
Binary file not shown.
BIN
tests/27_test_print_to.pyc
Normal file
BIN
tests/27_test_print_to.pyc
Normal file
Binary file not shown.
Reference in New Issue
Block a user