|
| 1 | +//test primary constructor-core dialect/net sdk |
| 2 | +FUNCTION Start( ) AS VOID |
| 3 | + LOCAL TypedCntr:=TestC1{1} AS TestC1 |
| 4 | + xAssert(TypedCntr:Value()==1) |
| 5 | + |
| 6 | + LOCAL PrimaryCntr:=TestC2{2} AS TestC2 |
| 7 | + xAssert(PrimaryCntr:Value==2) |
| 8 | + |
| 9 | + LOCAL BothCntr1:=TestC3{} AS TestC3 |
| 10 | + xAssert(BothCntr1:Value()==0) |
| 11 | + LOCAL BothCntr2:=TestC3{3} AS TestC3 |
| 12 | + xAssert(BothCntr2:Value()==3) |
| 13 | + LOCAL BothCntr3:=TestC3{3,1} AS TestC3 |
| 14 | + xAssert(BothCntr3:Value()==3) |
| 15 | + |
| 16 | + LOCAL TypedStr:=TestS1{1} AS TestS1 |
| 17 | + xAssert(TypedStr:Value()==1) |
| 18 | + |
| 19 | + LOCAL PrimaryStr:=TestS2{2} AS TestS2 |
| 20 | + xAssert(PrimaryStr:Value==2) |
| 21 | + |
| 22 | + LOCAL BothStr1:=TestS3{} AS TestS3 |
| 23 | + xAssert(BothStr1:Value()==0) |
| 24 | + LOCAL BothStr2:=TestS3{3} AS TestS3 |
| 25 | + xAssert(BothStr2:Value()==3) |
| 26 | + LOCAL BothStr3:=TestS3{3,1} AS TestS3 |
| 27 | + xAssert(BothStr3:Value()==3) |
| 28 | + |
| 29 | + LOCAL TypedRcd:=TestR1{1} AS TestR1 |
| 30 | + xAssert(TypedRcd:Value()==1) |
| 31 | + |
| 32 | + LOCAL PrimaryRcd:=TestR2{2} AS TestR2 |
| 33 | + xAssert(PrimaryRcd:Value==2) |
| 34 | + |
| 35 | + LOCAL BothRcd1:=TestR3{} AS TestR3 |
| 36 | + xAssert(BothRcd1:Value()==0) |
| 37 | + LOCAL BothRcd2:=TestR3{3} AS TestR3 |
| 38 | + xAssert(BothRcd2:Value()==3) |
| 39 | + LOCAL BothRcd3:=TestR3{3,1} AS TestR3 |
| 40 | + xAssert(BothRcd3:Value()==3) |
| 41 | + |
| 42 | + LOCAL TypedRStr:=TestRS1{1} AS TestRS1 |
| 43 | + xAssert(TypedRStr:Value()==1) |
| 44 | + |
| 45 | + LOCAL PrimaryRStr:=TestRS2{2} AS TestRS2 |
| 46 | + xAssert(PrimaryRStr:Value==2) |
| 47 | + |
| 48 | + LOCAL BothRStr1:=TestRS3{} AS TestRS3 |
| 49 | + xAssert(BothRStr1:Value()==0) |
| 50 | + LOCAL BothRStr2:=TestRS3{3} AS TestRS3 |
| 51 | + xAssert(BothRStr2:Value()==3) |
| 52 | + LOCAL BothRStr3:=TestRS3{3,1} AS TestRS3 |
| 53 | + xAssert(BothRStr3:Value()==3) |
| 54 | + |
| 55 | +RETURN |
| 56 | + |
| 57 | +#region Class |
| 58 | +CLASS TestC1 //Class with only a typed constructor |
| 59 | + PUBLIC CONSTRUCTOR (y AS INT) |
| 60 | + PUBLIC METHOD Value() AS INT |
| 61 | + RETURN 1 |
| 62 | +END CLASS |
| 63 | + |
| 64 | +CLASS TestC2(x AS INT) //Class with just a primary constructor |
| 65 | + PUBLIC Value:= x AS INT |
| 66 | +END CLASS |
| 67 | + |
| 68 | +CLASS TestC3 (x AS INT) //Class with a primary construstor and two typed constructor |
| 69 | + PUBLIC CONSTRUCTOR () |
| 70 | + SELF(0) |
| 71 | + PUBLIC CONSTRUCTOR(a AS INT, b AS INT) |
| 72 | + SELF(a) |
| 73 | + PUBLIC METHOD Value() AS INT |
| 74 | + RETURN x |
| 75 | +END CLASS |
| 76 | +#endregion |
| 77 | + |
| 78 | +#region Struct |
| 79 | +STRUCT TestS1 //Struct with only a typed constructor |
| 80 | + PUBLIC CONSTRUCTOR (y AS INT) |
| 81 | + PUBLIC METHOD Value() AS INT |
| 82 | + RETURN 1 |
| 83 | +END STRUCT |
| 84 | + |
| 85 | +STRUCT TestS2(x AS INT) //Struct with just a primary constructor |
| 86 | + PUBLIC Value:= x AS INT |
| 87 | +END STRUCT |
| 88 | + |
| 89 | +STRUCT TestS3 (x AS INT) //Struct with a primary construstor and two typed constructor |
| 90 | + PUBLIC CONSTRUCTOR () |
| 91 | + SELF(0) |
| 92 | + PUBLIC CONSTRUCTOR(a AS INT, b AS INT) |
| 93 | + SELF(a) |
| 94 | + PUBLIC METHOD Value() AS INT |
| 95 | + RETURN x |
| 96 | +END STRUCT |
| 97 | +#endregion |
| 98 | + |
| 99 | +#region Record |
| 100 | +RECORD TestR1 //Record with only a typed constructor |
| 101 | + PUBLIC CONSTRUCTOR (y AS INT) |
| 102 | + PUBLIC METHOD Value() AS INT |
| 103 | + RETURN 1 |
| 104 | +END RECORD |
| 105 | + |
| 106 | +RECORD TestR2(x AS INT) //Record with just a primary constructor |
| 107 | + PUBLIC Value:= x AS INT |
| 108 | +END RECORD |
| 109 | + |
| 110 | +RECORD TestR3 (x AS INT) //Record with a primary construstor and two typed constructor |
| 111 | + PUBLIC CONSTRUCTOR () |
| 112 | + SELF(0) |
| 113 | + PUBLIC CONSTRUCTOR(a AS INT, b AS INT) |
| 114 | + SELF(a) |
| 115 | + PUBLIC METHOD Value() AS INT |
| 116 | + RETURN x |
| 117 | +END RECORD |
| 118 | +#endregion |
| 119 | + |
| 120 | +#region Record Struct |
| 121 | +RECORD STRUCT TestRS1 //Record Struct with only a typed constructor |
| 122 | + PUBLIC CONSTRUCTOR (y AS INT) |
| 123 | + PUBLIC METHOD Value() AS INT |
| 124 | + RETURN 1 |
| 125 | +END STRUCT |
| 126 | + |
| 127 | +RECORD STRUCT TestRS2(x AS INT) //Record Struct with just a primary constructor |
| 128 | + PUBLIC Value:= x AS INT |
| 129 | +END STRUCT |
| 130 | + |
| 131 | +RECORD STRUCT TestRS3 (x AS INT) //Record Struct with a primary construstor and two typed constructor |
| 132 | + PUBLIC CONSTRUCTOR () |
| 133 | + SELF(0) |
| 134 | + PUBLIC CONSTRUCTOR(a AS INT, b AS INT) |
| 135 | + SELF(a) |
| 136 | + PUBLIC METHOD Value() AS INT |
| 137 | + RETURN x |
| 138 | +END STRUCT |
| 139 | +#endregion |
| 140 | + |
| 141 | +PROC xAssert(l AS LOGIC) |
| 142 | +IF .NOT. l |
| 143 | + THROW Exception{"Incorrect result in line " + System.Diagnostics.StackTrace{TRUE}:GetFrame(1):GetFileLineNumber():ToString()} |
| 144 | +END IF |
| 145 | +? "Assertion passed" |
| 146 | +RETURN |
0 commit comments