Merge pull request #1 from dpogue/master

Improved tests and support PRINT_*_TO
This commit is contained in:
Michael Hansen
2011-09-18 00:51:59 -07:00
63 changed files with 34 additions and 5 deletions

View File

@@ -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;
};

View File

@@ -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 {

View File

@@ -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

Binary file not shown.

BIN
tests/15_test_del.pyc Normal file

Binary file not shown.

BIN
tests/15_test_docstring.pyc Normal file

Binary file not shown.

BIN
tests/15_test_empty.pyc Normal file

Binary file not shown.

Binary file not shown.

BIN
tests/15_test_exec.pyc Normal file

Binary file not shown.

Binary file not shown.

BIN
tests/15_test_functions.pyc Normal file

Binary file not shown.

BIN
tests/15_test_global.pyc Normal file

Binary file not shown.

BIN
tests/15_test_globals.pyc Normal file

Binary file not shown.

BIN
tests/15_test_import.pyc Normal file

Binary file not shown.

BIN
tests/15_test_integers.pyc Normal file

Binary file not shown.

BIN
tests/15_test_lambda.pyc Normal file

Binary file not shown.

BIN
tests/15_test_loops.pyc Normal file

Binary file not shown.

BIN
tests/15_test_misc.pyc Normal file

Binary file not shown.

Binary file not shown.

BIN
tests/15_test_print.pyc Normal file

Binary file not shown.

Binary file not shown.

BIN
tests/15_test_slices.pyc Normal file

Binary file not shown.

Binary file not shown.

BIN
tests/15_test_tuples.pyc Normal file

Binary file not shown.

BIN
tests/15_tuple_params.pyc Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
tests/22_test_class.pyc Normal file

Binary file not shown.

BIN
tests/22_test_del.pyc Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
tests/22_test_docstring.pyc Normal file

Binary file not shown.

BIN
tests/22_test_empty.pyc Normal file

Binary file not shown.

Binary file not shown.

BIN
tests/22_test_exec.pyc Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
tests/22_test_functions.pyc Normal file

Binary file not shown.

BIN
tests/22_test_global.pyc Normal file

Binary file not shown.

BIN
tests/22_test_globals.pyc Normal file

Binary file not shown.

BIN
tests/22_test_import.pyc Normal file

Binary file not shown.

BIN
tests/22_test_import_as.pyc Normal file

Binary file not shown.

BIN
tests/22_test_iterators.pyc Normal file

Binary file not shown.

BIN
tests/22_test_lambda.pyc Normal file

Binary file not shown.

Binary file not shown.

BIN
tests/22_test_loops.pyc Normal file

Binary file not shown.

BIN
tests/22_test_loops2.pyc Normal file

Binary file not shown.

BIN
tests/22_test_misc.pyc Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
tests/22_test_print.pyc Normal file

Binary file not shown.

BIN
tests/22_test_print_to.pyc Normal file

Binary file not shown.

Binary file not shown.

BIN
tests/22_test_slices.pyc Normal file

Binary file not shown.

Binary file not shown.

BIN
tests/22_test_tuples.pyc Normal file

Binary file not shown.

BIN
tests/22_test_yield.pyc Normal file

Binary file not shown.

Binary file not shown.

BIN
tests/27_print_to.pyc Normal file

Binary file not shown.

BIN
tests/27_test_print_to.pyc Normal file

Binary file not shown.