00001 // 00002 // tests/frame.h 00003 // 00004 // Copyright (c) 2008-2009, Mike Austin 00005 // All rights reserved. 00006 // 00007 00008 namespace impulse { 00009 00010 class FrameTest : public UnitTest { 00011 00012 public: 00013 00014 static UnitTest& create() { return *new FrameTest(); } 00015 00016 void runTests(); 00017 00018 }; 00019 00020 00021 void FrameTest::runTests() 00022 { 00023 cout << "Testing Frame..." << endl; 00024 cout << "------------------------------------------------------------" << endl; 00025 00026 if (true) 00027 { 00028 Frame frame; 00029 Symbol foo( "foo" ); 00030 00031 OUTPUT( "-- Set and get slots" ); 00032 ASSERT( frame.setSlot( foo, 10.0 ).getFloat() == Value( 10.0 ).getFloat() ); 00033 ASSERT( frame.getSlot( foo ).getFloat() == 10.0 ); 00034 ASSERT( frame.getSlot( foo ).getFloat() != 15.0 ); 00035 00036 Array args; 00037 args.push( 10 ); 00038 00039 OUTPUT( "-- eval()" ); 00040 00041 ASSERT( Value( 10.0 ).eval( args, 10.0 ).getFloat() == 10.0 ); 00042 ASSERT( frame.eval( args, 10.0 ).getFrame() == &frame ); 00043 00044 OUTPUT( "-- send()" ); 00045 ASSERT( frame.send( foo, args ).getFrame() == frame.getSlot( foo ).getFrame() ); 00046 /* 00047 trace << "frame.send( &frame, Symbol::at(\"test\"), args )" << endl; 00048 trace << "--------------------" << endl; 00049 00050 OUTPUT( "-- Proto lookup" ); 00051 frame.proto() = _Object_.getFrame(); 00052 00053 frame.send( Symbol::at("test"), args ); 00054 ASSERT( frame.getSlot( Symbol::at("foo") ).getFloat() == 15.0 ); 00055 */ 00056 } 00057 00058 cout << "------------------------------------------------------------" << endl; 00059 cout << endl; 00060 } 00061 00062 }