|
| 1 | +module Core_access |
| 2 | + |
| 3 | +#light |
| 4 | +let failures = ref [] |
| 5 | + |
| 6 | +let report_failure (s : string) = |
| 7 | + stderr.Write" NO: " |
| 8 | + stderr.WriteLine s |
| 9 | + failures.Value <- failures.Value @ [s] |
| 10 | + |
| 11 | +let test (s : string) b = |
| 12 | + stderr.Write(s) |
| 13 | + if b then stderr.WriteLine " OK" |
| 14 | + else report_failure (s) |
| 15 | + |
| 16 | +(*--------------------*) |
| 17 | + |
| 18 | +// Test cases for bug://1562 |
| 19 | +// Checking that generated signature can be compiled against the file. |
| 20 | + |
| 21 | +type internal typInternal = | AAA1 |
| 22 | +type private typPrivate = | AAA2 |
| 23 | +type public typPublic = | AAA3 |
| 24 | +type typDefault = | AAA4 |
| 25 | +type internal rrr = | AAA |
| 26 | + |
| 27 | +let internal ValInternal = 1212 |
| 28 | +let private ValPrivate = 1212 |
| 29 | +let public ValPublic = 1212 |
| 30 | +let ValDefault = 1212 |
| 31 | + |
| 32 | +[<Sealed>] |
| 33 | +type MyClassFields = |
| 34 | + val internal fieldInternal : int |
| 35 | + val private fieldPrivate : int |
| 36 | + val public fieldPublic : int |
| 37 | + |
| 38 | +[<Sealed>] |
| 39 | +type MyClassMutableFields = |
| 40 | + val mutable internal mfieldInternal : int |
| 41 | + val mutable private mfieldPrivate : int |
| 42 | + val mutable public mfieldPublic : int |
| 43 | + |
| 44 | +[<Sealed>] |
| 45 | +type MyClassStaticMembers = |
| 46 | + static member internal SInternal = 12 |
| 47 | + static member private SPrivate = 12 |
| 48 | + static member public SPublic = 12 |
| 49 | + static member SDefault = 12 |
| 50 | + static member internal SMInternal() = 12 |
| 51 | + static member private SMPrivate() = 12 |
| 52 | + static member public SMPublic() = 12 |
| 53 | + static member SMDefault() = 12 |
| 54 | + |
| 55 | +[<Sealed>] |
| 56 | +type MyClassPropertiyGetters = |
| 57 | + member internal x.InstInternal = 12 |
| 58 | + member private x.InstPrivate = 12 |
| 59 | + member public x.InstPublic = 12 |
| 60 | + member x.InstDefault = 12 |
| 61 | + |
| 62 | +type MyClassExplicitCtors = |
| 63 | + val v : int |
| 64 | + internal new(x) = { v = x } |
| 65 | + private new(x,y) = { v = x + y} |
| 66 | + public new(x,y,z) = { v = x + y + z} |
| 67 | + |
| 68 | +type MyClassExplicitCtors2 = |
| 69 | + new() = {} |
| 70 | + internal new(x) = let v : int = x in {} |
| 71 | + private new(x,y) = let v : int = x + y in {} |
| 72 | + public new(x,y,z) = let v : int = x + y + z in {} |
| 73 | + |
| 74 | +[<Sealed>] |
| 75 | +type MyClassPropertyGetSetterMatrix = |
| 76 | + //-- |
| 77 | + member obj.PropGetSetInternalInternal |
| 78 | + with internal get() = 1 |
| 79 | + and internal set(x:int) = () |
| 80 | + member obj.PropGetSetInternalPrivate |
| 81 | + with internal get() = 1 |
| 82 | + and private set(x:int) = () |
| 83 | + member obj.PropGetSetInternalPublic |
| 84 | + with internal get() = 1 |
| 85 | + and public set(x:int) = () |
| 86 | + //-- |
| 87 | + member obj.PropGetSetPrivateInternal |
| 88 | + with private get() = 1 |
| 89 | + and internal set(x:int) = () |
| 90 | + member obj.PropGetSetPrivatePrivate |
| 91 | + with private get() = 1 |
| 92 | + and private set(x:int) = () |
| 93 | + member obj.PropGetSetPrivatePublic |
| 94 | + with private get() = 1 |
| 95 | + and public set(x:int) = () |
| 96 | + //-- |
| 97 | + member obj.PropGetSetPublicInternal |
| 98 | + with public get() = 1 |
| 99 | + and internal set(x:int) = () |
| 100 | + member obj.PropGetSetPublicPrivate |
| 101 | + with public get() = 1 |
| 102 | + and private set(x:int) = () |
| 103 | + member obj.PropGetSetPublicPublic |
| 104 | + with public get() = 1 |
| 105 | + and public set(x:int) = () |
| 106 | + |
| 107 | +[<Sealed>] |
| 108 | +type MyClassImplicitCtorInternal internal() = |
| 109 | + member obj.Res = 12 |
| 110 | + |
| 111 | +[<Sealed>] |
| 112 | +type MyClassImplicitCtorPrivate private() = |
| 113 | + member obj.Res = 12 |
| 114 | + |
| 115 | +module internal ModInternal = begin end |
| 116 | +module private ModPrivate = begin end |
| 117 | +module public ModPublic = begin end |
| 118 | + |
| 119 | +type recordRepInternal = internal { rfA1 : int } |
| 120 | +type recordRepPrivate = private { rfA2 : int } |
| 121 | +type recordRepPublic = public { rfA3 : int } |
| 122 | + |
| 123 | +type dtypeRepInternal = internal | AA1 | BB1 |
| 124 | +type dtypeRepPrivate = private | AA2 | BB2 |
| 125 | +type dtypeRepPublic = public | AA3 | BB3 |
| 126 | + |
| 127 | +type internal dtypeRepPublic2 = private | AA3 | BB3 |
| 128 | +type private dtypeRepPublic3 = internal | AA3 | BB3 |
| 129 | + |
| 130 | +type internal dtypeRepPublic4 = |
| 131 | + private |
| 132 | + | AA3 |
| 133 | + | BB3 |
| 134 | + |
| 135 | +module internal M = |
| 136 | + module private PP = |
| 137 | + type dtypeRepPublic5 = |
| 138 | + | AA3 |
| 139 | + | BB3 |
| 140 | + |
| 141 | +module private M2 = |
| 142 | + module internal P = |
| 143 | + let vv = 12 |
| 144 | + |
| 145 | + |
| 146 | +module RestrictedRecordsAndUnionsUsingPrivateAndInternalTypes = |
| 147 | + |
| 148 | + module public Test1 = |
| 149 | + |
| 150 | + type internal Data = |
| 151 | + { |
| 152 | + Datum: int |
| 153 | + } |
| 154 | + |
| 155 | + type public Datum = |
| 156 | + internal |
| 157 | + { |
| 158 | + Thing: Data |
| 159 | + } |
| 160 | + |
| 161 | + type public Datum2 = |
| 162 | + internal | A of Data * Data | B of Data |
| 163 | + |
| 164 | + module public Test2 = |
| 165 | + |
| 166 | + type internal Data = |
| 167 | + { |
| 168 | + Datum: int |
| 169 | + } |
| 170 | + |
| 171 | + type internal Datum = |
| 172 | + { |
| 173 | + Thing: Data |
| 174 | + } |
| 175 | + |
| 176 | + type internal Datum2 = |
| 177 | + | A of Data * Data | B of Data |
| 178 | + |
| 179 | + module public Test3 = |
| 180 | + |
| 181 | + type public Data = |
| 182 | + internal |
| 183 | + { |
| 184 | + Datum: int |
| 185 | + } |
| 186 | + |
| 187 | + type internal Datum = |
| 188 | + { |
| 189 | + Thing: Data |
| 190 | + } |
| 191 | + |
| 192 | + type internal Datum2 = |
| 193 | + internal | A of Data * Data | B of Data |
| 194 | + |
| 195 | + |
| 196 | + module public Test4 = |
| 197 | + |
| 198 | + type internal Data = |
| 199 | + { |
| 200 | + Datum: int |
| 201 | + } |
| 202 | + |
| 203 | + type public Datum = |
| 204 | + internal |
| 205 | + { |
| 206 | + Thing: Data |
| 207 | + } |
| 208 | + |
| 209 | + type public Datum2 = |
| 210 | + internal | A of Data * Data | B of Data |
| 211 | + |
| 212 | + |
| 213 | + module public Test5 = |
| 214 | + |
| 215 | + type private Data = |
| 216 | + { |
| 217 | + Datum: int |
| 218 | + } |
| 219 | + |
| 220 | + type public Datum = |
| 221 | + private |
| 222 | + { |
| 223 | + Thing: Data |
| 224 | + } |
| 225 | + |
| 226 | + type public Datum2 = |
| 227 | + private | A of Data * Data | B of Data |
| 228 | + |
| 229 | + |
| 230 | + module Test6 = |
| 231 | + module internal HelperModule = |
| 232 | + |
| 233 | + type public Data = |
| 234 | + private |
| 235 | + { |
| 236 | + Datum: int |
| 237 | + } |
| 238 | + |
| 239 | + let internal handle (data:Data): int = data.Datum |
| 240 | + |
| 241 | + module public Module = |
| 242 | + |
| 243 | + type public Data = |
| 244 | + private |
| 245 | + { |
| 246 | + Thing: HelperModule.Data |
| 247 | + } |
| 248 | + |
| 249 | + let public getInt (data:Data): int = HelperModule.handle data.Thing |
| 250 | + |
| 251 | + module Test7 = |
| 252 | + module internal HelperModule = |
| 253 | + |
| 254 | + type Data = |
| 255 | + { |
| 256 | + Datum: int |
| 257 | + } |
| 258 | + |
| 259 | + let handle (data:Data): int = data.Datum |
| 260 | + |
| 261 | + module Module = |
| 262 | + |
| 263 | + type Data = |
| 264 | + internal |
| 265 | + { |
| 266 | + Thing: HelperModule.Data |
| 267 | + } |
| 268 | + |
| 269 | + let getInt (data:Data): int = HelperModule.handle data.Thing |
| 270 | + |
| 271 | + |
| 272 | + (*--------------------*) |
| 273 | + |
| 274 | +#if TESTS_AS_APP |
| 275 | +let RUN() = failures.Value |
| 276 | +#else |
| 277 | +let aa = |
| 278 | + match failures.Value with |
| 279 | + | [] -> |
| 280 | + stdout.WriteLine "Test Passed" |
| 281 | + System.IO.File.WriteAllText("test.ok","ok") |
| 282 | + exit 0 |
| 283 | + | _ -> |
| 284 | + stdout.WriteLine "Test Failed" |
| 285 | + exit 1 |
| 286 | +#endif |
| 287 | + |
0 commit comments