Exemplo n.º 1
0
While::While(class Ast* ast, const location& loc, AstNode* _test, AstNode* _body,
		AstNode* _orelse) :
    Stmt(AST_WHILE, ast, loc), test(NULL)
{
	SetTest(_test);
	SetBody(_body);
	SetOrElse(_orelse);
}
Exemplo n.º 2
0
If::If(class Ast* _ast, const location& _loc,  AstNode *_test,
		AstNode *_body, AstNode *_orelse):
		Stmt(AST_IF, _ast, _loc), test(NULL)
{
	SetTest(_test);
	SetBody(_body);
	SetOrElse(_orelse);
}
Exemplo n.º 3
0
void CheckerPropagate::FindTest(Bit *base_bit, Bit *point_bit)
{
  SetBaseBit(base_bit, point_bit);

  // get the sufficient conditions we can use, if there are any.
  Vector<CheckerPropagate*> propagate_list;
  GetSufficientConditions(this, point_bit, &propagate_list);

  if (!propagate_list.Empty()) {
    // sort the propagations according to how much we like their directions.
    SortVector<CheckerPropagate*,CompareSufficientPropagate>(&propagate_list);

    // use the best direction we found in the sufficient conditions.
    m_where = propagate_list[0]->m_where;
    propagate_list[0]->m_where = NULL;

    for (size_t ind = 0; ind < propagate_list.Size(); ind++)
      delete propagate_list[ind];
  }
  else {
    // do what propagation we can based on the converted bit.
    SetTest(point_bit);
  }
}
/*
 * Parse command line information.
 *      argc, argv: the usual command line argument count and strings
 *
 * Return: Void
 *    exit EXIT_FAILURE if error is encountered.
 *
 * Modification:
 * 	2004/08/18 Albert Cheng.  Add extra_parse feature.
 */
void TestParseCmdLine(int argc, char *argv[])
{
    int ret_code;

    while (argv++, --argc > 0){
	if ((HDstrcmp(*argv, "-verbose") == 0) ||
				(HDstrcmp(*argv, "-v") == 0)) {
	    if (argc > 0){
		--argc; ++argv;
		ParseTestVerbosity(*argv);
	    }else{
		TestUsage();
		exit(EXIT_FAILURE);
	    }
	}
	else if (((HDstrcmp(*argv, "-exclude") == 0) ||
				    (HDstrcmp(*argv, "-x") == 0))) {
	    if (argc > 0){
		--argc; ++argv;
		SetTest(*argv, SKIPTEST);
	    }else{
		TestUsage();
		exit(EXIT_FAILURE);
	    }
	}
	else if (((HDstrcmp(*argv, "-begin") == 0) ||
				    (HDstrcmp(*argv, "-b") == 0))) {
	    if (argc > 0){
		--argc; ++argv;
		SetTest(*argv, BEGINTEST);
	    }else{
		TestUsage();
		exit(EXIT_FAILURE);
	    }
	}
	else if (((HDstrcmp(*argv, "-only") == 0) ||
				    (HDstrcmp(*argv, "-o") == 0))) {
	    if (argc > 0){
		int Loop;
		--argc; ++argv;
		/* Skip all tests, then activate only one. */
		for (Loop = 0; Loop < Index; Loop++)
		    Test[Loop].SkipFlag = 1;
		SetTest(*argv, ONLYTEST);
	    }else{
		TestUsage();
		exit(EXIT_FAILURE);
	    }
	}
	else if ((HDstrcmp(*argv, "-summary") == 0) || (HDstrcmp(*argv, "-s") == 0))
            Summary = 1;
	else if ((HDstrcmp(*argv, "-help") == 0) || (HDstrcmp(*argv, "-h") == 0)) {
            TestUsage();
            exit(EXIT_SUCCESS);
        }
	else if ((HDstrcmp(*argv, "-cleanoff") == 0) || (HDstrcmp(*argv, "-c") == 0))
	    SetTestNoCleanup();
	else {
	    /* non-standard option.  Break out. */
	    break;
	}

    }

    /* Call extra parsing function if provided. */
    if (NULL != TestPrivateParser){
	ret_code=TestPrivateParser(argc+1, argv-1);
	if (ret_code != 0)
	    exit(EXIT_FAILURE);
    }
}
Exemplo n.º 5
0
TestView::TestView(const BRect &frame,const char *name, BMessage *test,
					const int32 &resize,const int32 &flags)
 :	BView(frame,name,resize,flags),
 	fTest(NULL)
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	// Find the longest name in all the tests
	RuleRunner::GetTestTypes(fTestTypes);
	int32 i = 0;
	BString teststr, widesttest, widestmode;
	while (fTestTypes.FindString("tests",i,&teststr) == B_OK)
	{
		i++;
		if (teststr.CountChars() > widesttest.CountChars())
			widesttest = teststr;
	}
	
	// This will hopefully accomodate some of the attribute strings
	teststr = "Netpositive Password";
	if (teststr.CountChars() > widesttest.CountChars())
		widesttest = teststr;
	
	fTestButton = new BButton(BRect(0,0,1,1),"testbutton",widesttest.String(),
								new BMessage(M_SHOW_TEST_MENU));
	fTestButton->ResizeToPreferred();
	AddChild(fTestButton);
	
	BRect rect = fTestButton->Frame();
	rect.OffsetBy(rect.Width() + 10.0,0.0);
	
	// Find the longest name in all the modes
	BMessage modes;
	RuleRunner::GetModes(modes);
	i = 0;
	while (modes.FindString("modes",i,&teststr) == B_OK)
	{
		i++;
		if (teststr.CountChars() > widestmode.CountChars())
			widestmode = teststr;
	}
	
	fModeButton = new BButton(rect,"modebutton",widestmode.String(),
								new BMessage(M_SHOW_MODE_MENU));
	fModeButton->ResizeToPreferred();
	AddChild(fModeButton);
	
	rect = fModeButton->Frame();
	rect.OffsetBy(rect.Width() + 5,0);
	rect.right = rect.left + StringWidth("application/x-vnd.dw-foo") + 5;
	fValueBox = new AutoTextControl(rect,"valuebox",NULL,NULL,
									new BMessage(M_VALUE_CHANGED),
									B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	AddChild(fValueBox);
	fValueBox->SetDivider(0);
	if (fValueBox->Bounds().Height() < fModeButton->Bounds().Height())
		fValueBox->MoveBy(0.0,(fModeButton->Bounds().Height() - fValueBox->Bounds().Height()) / 2.0);
	

	SetupTestMenu();
		
	bool usedefaults = false;
	if (test)
	{
		STRACE(("\nTestView::TestView: test parameter\n"));
		MSGTRACE(test);
		
		fTest = new BMessage(*test);
		BString str;
		
		if (!SetTest(fTest))
			usedefaults = true;
		
		if (fTest->FindString("mode",&str) == B_OK)
			SetMode(str.String());
		else
		{
			fTest->FindString("name",&str);
			modes.MakeEmpty();
			RuleRunner::GetCompatibleModes(str.String(),modes);
			modes.FindString("modes",0,&str);
			SetMode(str.String());
		}
		
		if (fTest->FindString("value",&str) == B_OK)
			fValueBox->SetText(str.String());
	}
	else
		usedefaults = true;
	
	if (usedefaults)
	{
		if (!fTest)
			fTest = new BMessage;
		
		BString str;
		fTestTypes.FindString("tests",0,&str);
		
		BMessage newtest;
		newtest.AddString("name",str);
		
		modes.MakeEmpty();
		RuleRunner::GetCompatibleModes(str.String(),modes);
		modes.FindString("modes",0,&str);
		
		newtest.AddString("mode",str);
		newtest.AddString("value","");
		
		SetTest(&newtest);
		SetMode(str.String());
	}
}
Exemplo n.º 6
0
void
TestView::MessageReceived(BMessage *msg)
{
	switch (msg->what)
	{
		case M_TEST_CHOSEN:
		{
			SetTest(msg);
			break;
		}
		case M_MODE_CHOSEN:
		{
			BString mode;
			if (msg->FindString("mode",&mode) != B_OK)
				break;
			
			SetMode(mode.String());
			break;
		}
		case M_VALUE_CHANGED:
		{
			BString str;
			if (fTest->FindString("value",&str) == B_OK)
				fTest->ReplaceString("value",fValueBox->Text());
			else
				fTest->AddString("value",fValueBox->Text());
			break;
		}
		case M_SHOW_TEST_MENU:
		{
			BPopUpMenu *menu = (BPopUpMenu*)BPopUpMenu::Instantiate(&fArchivedTestMenu);
			menu->SetTargetForItems(this);
			
			for (int32 i = 0; i < menu->CountItems(); i++)
			{
				BMenuItem *item = menu->ItemAt(i);
				if (item->Submenu())
					item->Submenu()->SetTargetForItems(this);
			}
			
			BPoint pt;
			uint32 buttons;
			GetMouse(&pt,&buttons);
			ConvertToScreen(&pt);
			pt.x -= 10.0;
			if (pt.x < 0.0)
				pt.x = 0.0;
			
			pt.y -= 10.0;
			if (pt.y < 0.0)
				pt.y = 0.0;
			
			menu->SetAsyncAutoDestruct(true);
			menu->Go(pt,true,true,true);
			break;
		}
		case M_SHOW_TYPE_MENU:
		{
			BPopUpMenu *menu = (BPopUpMenu*)BPopUpMenu::Instantiate(&gArchivedTypeMenu);
			menu->SetTargetForItems(this);
			
			for (int32 i = 0; i < menu->CountItems(); i++)
			{
				BMenuItem *item = menu->ItemAt(i);
				if (item->Submenu())
					item->Submenu()->SetTargetForItems(this);
			}
			
			BPoint pt;
			uint32 buttons;
			GetMouse(&pt,&buttons);
			ConvertToScreen(&pt);
			pt.x -= 10.0;
			if (pt.x < 0.0)
				pt.x = 0.0;
			
			pt.y -= 10.0;
			if (pt.y < 0.0)
				pt.y = 0.0;
			
			menu->SetAsyncAutoDestruct(true);
			menu->Go(pt,true,true,true);
			break;
		}
		case M_SHOW_MODE_MENU:
		{
			ShowModeMenu();
			break;
		}
		default:
		{
			BView::MessageReceived(msg);
			break;
		}
	}

}