12#include <unordered_set>
27 bool error = !compiler.
Compile( expr, &ucode, &preflightContext );
47 result = *ucode.
Run( &context );
48 ok = (result.
EqualTo( &expectedResult) );
55int main(
int argc,
char *argv[] )
76 NETCLASSPTR netclass1(
new NETCLASS(
"HV") );
77 NETCLASSPTR netclass2(
new NETCLASS(
"otherClass" ) );
82 net1info->SetClass( netclass1 );
83 net2info->SetClass( netclass2 );
96 testEvalExpr(
"A.fromTo('U1', 'U3') && A.NetClass == 'DDR3_A' ",
VAL(0),
false, &trackA, &trackB );
101 testEvalExpr(
"A.type == 'Pad' && B.type == 'Pad' && (A.existsOnLayer('F.Cu'))",
VAL( 0.0 ),
false, &trackA, &trackB );
103 testEvalExpr(
"A.Width > B.Width",
VAL( 0.0 ),
false, &trackA, &trackB );
104 testEvalExpr(
"A.Width + B.Width",
VAL( Mils2iu(10) + Mils2iu(20) ),
false, &trackA, &trackB );
107 testEvalExpr(
"(A.Netclass == 'HV') && (B.netclass == 'otherClass') && (B.netclass != 'F.Cu')",
VAL( 1.0 ),
false, &trackA, &trackB );
108 testEvalExpr(
"A.Netclass + 1.0",
VAL( 1.0 ),
false, &trackA, &trackB );
109 testEvalExpr(
"A.type == 'Track' && B.type == 'Track' && A.layer == 'F.Cu'",
VAL( 0.0 ),
false, &trackA, &trackB );
110 testEvalExpr(
"(A.type == 'Track') && (B.type == 'Track') && (A.layer == 'F.Cu')",
VAL( 0.0 ),
false, &trackA, &trackB );
void SetNet(NETINFO_ITEM *aNetInfo)
Set a NET_INFO object for the item.
wxString GetNetClassName() const
Returns the name of the effective netclass.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Information pertinent to a Pcbnew printed circuit board.
const NETINFO_LIST & GetNetInfo() const
bool Compile(const wxString &aString, UCODE *aCode, CONTEXT *aPreflightContext)
VALUE * Run(CONTEXT *ctx)
virtual bool EqualTo(CONTEXT *aCtx, const VALUE *b) const
A collection of nets and the parameters used to route or test these nets.
Handle the data for a net.
Container for NETINFO_ITEM elements, which are the nets.
void SetItems(BOARD_ITEM *a, BOARD_ITEM *b=nullptr)
virtual void SetWidth(int aWidth)
Provide class metadata.Helper macro to map type hashes to names.
static PROPERTY_MANAGER & Instance()
void Rebuild()
Rebuild the list of all registered properties.
bool testEvalExpr(const std::string expr, LIBEVAL::VALUE expectedResult, bool expectError=false, BOARD_ITEM *itemA=nullptr, BOARD_ITEM *itemB=nullptr)