Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

interclass constraints not working #11

Open
ElectronicBatman opened this issue Jun 8, 2023 · 0 comments
Open

interclass constraints not working #11

ElectronicBatman opened this issue Jun 8, 2023 · 0 comments

Comments

@ElectronicBatman
Copy link

I have two classes with simple public members, when I provide constraints which define dependency between classes, I dont see any randomization
e.g.

#include <crave/ConstrainedRandom.hpp>
#include <crave/experimental/Experimental.hpp>
#include <boost/format.hpp>
#include <iostream>

using namespace crave;
class class_a : public crv_sequence_item {
 public:
 crv_variable<unsigned int> num;
 
  crv_constraint legal_num_class_C{ num() < 10 };

 class_a(crave::crv_object_name name = "class_a") {
    
 }
 void print(){
   std::cout<<" CLASS A num "<<num<<"\n";

 }
};

class class_b : public crv_sequence_item {
 public:
 crv_variable<unsigned int> powr;

 class_b(crave::crv_object_name name = "class_b") {
   
 }
 void print(){
   std::cout<<" CLASS B POW "<<powr<<"\n";

 }
};


int main(int argc, char* argv[]) {
  crave::init("crave.cfg");
  crave::set_global_seed(123456789);

  class_a a("a");
  class_b b("b");

  crv_constraint legal_pow_class_{ b.powr() == (1<<a.num()) };

  CHECK(a.randomize());
  CHECK(b.randomize());
  a.print();
  b.print();
}

I get values of num and powr as zero when printed
CLASS A num 0
CLASS B POW 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant