|
10 | 10 | import org.eclipse.core.runtime.CoreException; |
11 | 11 |
|
12 | 12 | import com.abstratt.mdd.core.runtime.types.BooleanType; |
| 13 | +import com.abstratt.mdd.core.runtime.types.DateTimeType; |
13 | 14 | import com.abstratt.mdd.core.runtime.types.DateType; |
14 | 15 | import com.abstratt.mdd.core.runtime.types.IntegerType; |
15 | 16 | import com.abstratt.mdd.core.runtime.types.PrimitiveType; |
@@ -254,7 +255,50 @@ public void testLiteral() throws CoreException { |
254 | 255 | TestCase.assertEquals(8, created.getMonthValue()); |
255 | 256 | TestCase.assertEquals(30, created.getDayOfMonth()); |
256 | 257 | } |
| 258 | + |
| 259 | + public void testMakeDateTime() throws CoreException { |
| 260 | + String model = ""; |
| 261 | + model += "model tests;\n"; |
| 262 | + model += "import mdd_types;\n"; |
| 263 | + model += "class DateUtil\n"; |
| 264 | + model += "static operation createDateTime() : DateTime;\n"; |
| 265 | + model += "begin\n"; |
| 266 | + model += " return Date#make(2011, 08, 30).at(Time#make(20, 15, 30, 375));\n"; |
| 267 | + model += "end;\n"; |
| 268 | + model += "end;\n"; |
| 269 | + model += "end."; |
257 | 270 |
|
| 271 | + parseAndCheck(model); |
| 272 | + LocalDateTime created = ((DateTimeType) runStaticOperation("tests::DateUtil", "createDateTime")).primitiveValue(); |
| 273 | + TestCase.assertEquals(2011, created.getYear()); |
| 274 | + TestCase.assertEquals(8 , created.getMonthValue()); |
| 275 | + TestCase.assertEquals(30, created.getDayOfMonth()); |
| 276 | + TestCase.assertEquals(20, created.getHour()); |
| 277 | + TestCase.assertEquals(15, created.getMinute()); |
| 278 | + TestCase.assertEquals(30, created.getSecond()); |
| 279 | + TestCase.assertEquals(375000000, created.getNano()); |
| 280 | + } |
| 281 | + |
| 282 | + public void testMakeTime() throws CoreException { |
| 283 | + String model = ""; |
| 284 | + model += "model tests;\n"; |
| 285 | + model += "import mdd_types;\n"; |
| 286 | + model += "class DateUtil\n"; |
| 287 | + model += "static operation createTime() : Time;\n"; |
| 288 | + model += "begin\n"; |
| 289 | + model += " return Time#make(20, 15, 30, 375);\n"; |
| 290 | + model += "end;\n"; |
| 291 | + model += "end;\n"; |
| 292 | + model += "end."; |
| 293 | + |
| 294 | + parseAndCheck(model); |
| 295 | + LocalTime created = ((TimeType) runStaticOperation("tests::DateUtil", "createTime")).primitiveValue(); |
| 296 | + TestCase.assertEquals(20, created.getHour()); |
| 297 | + TestCase.assertEquals(15, created.getMinute()); |
| 298 | + TestCase.assertEquals(30, created.getSecond()); |
| 299 | + TestCase.assertEquals(375000000, created.getNano()); |
| 300 | + } |
| 301 | + |
258 | 302 | public void testMakeDate() throws CoreException { |
259 | 303 | String model = ""; |
260 | 304 | model += "model tests;\n"; |
|
0 commit comments