tconstparser.pas 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  1. unit tconstparser;
  2. {$mode objfpc}{$H+}
  3. interface
  4. uses
  5. Classes, SysUtils, fpcunit, pastree, pscanner, tcbaseparser, testregistry, pparser;
  6. Type
  7. { TTestConstParser }
  8. TTestConstParser = Class(TTestParser)
  9. private
  10. FConst: TPasConst;
  11. FExpr: TPasExpr;
  12. FHint : string;
  13. FTyped: String;
  14. procedure DoParseConstUnTypedRange;
  15. Protected
  16. Function ParseConst(ASource : String) : TPasConst;
  17. Procedure CheckExprNameKindClass(AKind : TPasExprKind; AClass : TClass);
  18. Property TheConst : TPasConst Read FConst;
  19. Property TheExpr : TPasExpr Read FExpr;
  20. Property Hint : string Read FHint Write FHint;
  21. Property Typed : String Read FTyped Write FTyped;
  22. procedure SetUp; override;
  23. Public
  24. Procedure DoTestSimpleIntConst;
  25. Procedure DoTestSimpleFloatConst;
  26. Procedure DoTestSimpleStringConst;
  27. Procedure DoTestSimpleNilConst;
  28. Procedure DoTestSimpleBoolConst;
  29. Procedure DoTestSimpleIdentifierConst;
  30. Procedure DoTestSimpleSetConst;
  31. Procedure DoTestSimpleExprConst;
  32. Published
  33. Procedure TestSimpleIntConst;
  34. Procedure TestSimpleFloatConst;
  35. Procedure TestSimpleStringConst;
  36. Procedure TestSimpleNilConst;
  37. Procedure TestSimpleBoolConst;
  38. Procedure TestSimpleIdentifierConst;
  39. Procedure TestSimpleSetConst;
  40. Procedure TestSimpleExprConst;
  41. Procedure TestSimpleAbsoluteConst;
  42. Procedure TestSimpleIntConstDeprecatedMsg;
  43. Procedure TestSimpleIntConstDeprecated;
  44. Procedure TestSimpleFloatConstDeprecated;
  45. Procedure TestSimpleStringConstDeprecated;
  46. Procedure TestSimpleNilConstDeprecated;
  47. Procedure TestSimpleBoolConstDeprecated;
  48. Procedure TestSimpleIdentifierConstDeprecated;
  49. Procedure TestSimpleSetConstDeprecated;
  50. Procedure TestSimpleExprConstDeprecated;
  51. Procedure TestSimpleIntConstPlatform;
  52. Procedure TestSimpleFloatConstPlatform;
  53. Procedure TestSimpleStringConstPlatform;
  54. Procedure TestSimpleNilConstPlatform;
  55. Procedure TestSimpleBoolConstPlatform;
  56. Procedure TestSimpleIdentifierConstPlatform;
  57. Procedure TestSimpleSetConstPlatform;
  58. Procedure TestSimpleExprConstPlatform;
  59. Procedure TestSimpleIntConstExperimental;
  60. Procedure TestSimpleFloatConstExperimental;
  61. Procedure TestSimpleStringConstExperimental;
  62. Procedure TestSimpleNilConstExperimental;
  63. Procedure TestSimpleBoolConstExperimental;
  64. Procedure TestSimpleIdentifierConstExperimental;
  65. Procedure TestSimpleSetConstExperimental;
  66. Procedure TestSimpleExprConstExperimental;
  67. Procedure TestTypedIntConst;
  68. Procedure TestTypedFloatConst;
  69. Procedure TestTypedStringConst;
  70. Procedure TestTypedNilConst;
  71. Procedure TestTypedBoolConst;
  72. Procedure TestTypedIdentifierConst;
  73. Procedure TestTypedSetConst;
  74. Procedure TestTypedExprConst;
  75. Procedure TestRecordConst;
  76. Procedure TestArrayConst;
  77. Procedure TestRangeConst;
  78. Procedure TestRangeConstUnTyped;
  79. Procedure TestArrayOfRangeConst;
  80. end;
  81. { TTestResourcestringParser }
  82. TTestResourcestringParser = Class(TTestParser)
  83. private
  84. FExpr: TPasExpr;
  85. FHint : string;
  86. FTheStr: TPasResString;
  87. Protected
  88. Function ParseResourcestring(ASource : String) : TPasResString;
  89. Procedure CheckExprNameKindClass(AKind : TPasExprKind; AClass : TClass);
  90. Property Hint : string Read FHint Write FHint;
  91. Property TheStr : TPasResString Read FTheStr;
  92. Property TheExpr : TPasExpr Read FExpr;
  93. Public
  94. Procedure DoTestSimple;
  95. Procedure DoTestSum;
  96. Procedure DoTestSum2;
  97. Published
  98. Procedure TestSimple;
  99. Procedure TestSimpleDeprecated;
  100. Procedure TestSimplePlatform;
  101. Procedure TestSum1;
  102. Procedure TestSum1Deprecated;
  103. Procedure TestSum1Platform;
  104. Procedure TestSum2;
  105. Procedure TestSum2Deprecated;
  106. Procedure TestSum2Platform;
  107. end;
  108. implementation
  109. { TTestConstParser }
  110. function TTestConstParser.ParseConst(ASource: String): TPasConst;
  111. Var
  112. D : String;
  113. begin
  114. Add('Const');
  115. D:=' A ';
  116. If (Typed<>'') then
  117. D:=D+' : '+Typed+' ';
  118. D:=D+' = '+ASource;
  119. If Hint<>'' then
  120. D:=D+' '+Hint;
  121. Add(' '+D+';');
  122. ParseDeclarations;
  123. AssertEquals('One constant definition',1,Declarations.Consts.Count);
  124. AssertEquals('First declaration is constant definition.',TPasConst,TObject(Declarations.Consts[0]).ClassType);
  125. Result:=TPasConst(Declarations.Consts[0]);
  126. AssertNotNull(Result.Expr);
  127. FExpr:=Result.Expr;
  128. FConst:=Result;
  129. Definition:=Result;
  130. end;
  131. procedure TTestConstParser.CheckExprNameKindClass(
  132. AKind: TPasExprKind; AClass : TClass);
  133. begin
  134. AssertEquals('Correct name','A',TheConst.Name);
  135. AssertExpression('Const', TheExpr,aKind,AClass);
  136. end;
  137. procedure TTestConstParser.SetUp;
  138. begin
  139. inherited SetUp;
  140. Hint:='';
  141. end;
  142. procedure TTestConstParser.DoTestSimpleIntConst;
  143. begin
  144. ParseConst('1');
  145. AssertExpression('Integer Const',TheExpr,pekNumber,'1');
  146. end;
  147. procedure TTestConstParser.DoTestSimpleFloatConst;
  148. begin
  149. ParseConst('1.2');
  150. AssertExpression('Float const', TheExpr,pekNumber,'1.2');
  151. end;
  152. procedure TTestConstParser.DoTestSimpleStringConst;
  153. begin
  154. ParseConst('''test''');
  155. AssertExpression('String const', TheExpr,pekString,'''test''');
  156. end;
  157. procedure TTestConstParser.DoTestSimpleNilConst;
  158. begin
  159. ParseConst('Nil');
  160. CheckExprNameKindClass(pekNil,TNilExpr);
  161. end;
  162. procedure TTestConstParser.DoTestSimpleBoolConst;
  163. begin
  164. ParseConst('True');
  165. CheckExprNameKindClass(pekBoolConst,TBoolconstExpr);
  166. AssertEquals('Correct expression value',True,TBoolconstExpr(TheExpr).Value);
  167. end;
  168. procedure TTestConstParser.DoTestSimpleIdentifierConst;
  169. begin
  170. ParseConst('taCenter');
  171. AssertExpression('Enumeration const', theExpr,pekIdent,'taCenter');
  172. end;
  173. procedure TTestConstParser.DoTestSimpleSetConst;
  174. begin
  175. ParseConst('[taLeftJustify,taRightJustify]');
  176. CheckExprNameKindClass(pekSet,TParamsExpr);
  177. AssertEquals('Correct set count',2,Length(TParamsExpr(TheExpr).Params));
  178. AssertExpression('Set element 1',TParamsExpr(TheExpr).Params[0],pekIdent,'taLeftJustify');
  179. AssertExpression('Set element 2',TParamsExpr(TheExpr).Params[1],pekIdent,'taRightJustify');
  180. end;
  181. procedure TTestConstParser.DoTestSimpleExprConst;
  182. Var
  183. B : TBinaryExpr;
  184. begin
  185. ParseConst('1 + 2');
  186. CheckExprNameKindClass(pekBinary,TBinaryExpr);
  187. B:=TBinaryExpr(TheExpr);
  188. TAssert.AssertSame('B.Left.Parent=B',B,B.left.Parent);
  189. TAssert.AssertSame('B.right.Parent=B',B,B.right.Parent);
  190. AssertExpression('Left expression',B.Left,pekNumber,'1');
  191. AssertExpression('Right expression',B.Right,pekNumber,'2');
  192. end;
  193. procedure TTestConstParser.TestSimpleIntConst;
  194. begin
  195. DoTestSimpleIntConst
  196. end;
  197. procedure TTestConstParser.TestSimpleFloatConst;
  198. begin
  199. DoTestSimpleFloatConst
  200. end;
  201. procedure TTestConstParser.TestSimpleStringConst;
  202. begin
  203. DoTestSimpleStringConst
  204. end;
  205. procedure TTestConstParser.TestSimpleNilConst;
  206. begin
  207. DoTestSimpleNilConst
  208. end;
  209. procedure TTestConstParser.TestSimpleBoolConst;
  210. begin
  211. DoTestSimpleBoolConst
  212. end;
  213. procedure TTestConstParser.TestSimpleIdentifierConst;
  214. begin
  215. DoTestSimpleIdentifierConst
  216. end;
  217. procedure TTestConstParser.TestSimpleSetConst;
  218. begin
  219. DoTestSimpleSetConst
  220. end;
  221. procedure TTestConstParser.TestSimpleExprConst;
  222. begin
  223. DoTestSimpleExprConst;
  224. end;
  225. procedure TTestConstParser.TestSimpleAbsoluteConst;
  226. // Found in xi.pp
  227. begin
  228. Add('Const');
  229. Add(' Absolute = 1;');
  230. ParseDeclarations;
  231. AssertEquals('One constant definition',1,Declarations.Consts.Count);
  232. AssertEquals('First declaration is constant definition.',TPasConst,TObject(Declarations.Consts[0]).ClassType);
  233. end;
  234. procedure TTestConstParser.TestSimpleIntConstDeprecatedMsg;
  235. begin
  236. Hint:='deprecated ''this is old''' ;
  237. DoTestSimpleIntConst;
  238. CheckHint(hDeprecated);
  239. end;
  240. procedure TTestConstParser.TestSimpleIntConstDeprecated;
  241. begin
  242. Hint:='deprecated';
  243. DoTestSimpleIntConst;
  244. CheckHint(hDeprecated);
  245. end;
  246. procedure TTestConstParser.TestSimpleFloatConstDeprecated;
  247. begin
  248. Hint:='deprecated';
  249. DoTestSimpleIntConst;
  250. CheckHint(hDeprecated);
  251. end;
  252. procedure TTestConstParser.TestSimpleStringConstDeprecated;
  253. begin
  254. Hint:='deprecated';
  255. DoTestSimpleStringConst;
  256. CheckHint(hDeprecated);
  257. end;
  258. procedure TTestConstParser.TestSimpleNilConstDeprecated;
  259. begin
  260. Hint:='deprecated';
  261. DoTestSimpleNilConst;
  262. CheckHint(hDeprecated);
  263. end;
  264. procedure TTestConstParser.TestSimpleBoolConstDeprecated;
  265. begin
  266. Hint:='deprecated';
  267. DoTestSimpleBoolConst;
  268. CheckHint(hDeprecated);
  269. end;
  270. procedure TTestConstParser.TestSimpleIdentifierConstDeprecated;
  271. begin
  272. Hint:='deprecated';
  273. DoTestSimpleIdentifierConst;
  274. CheckHint(hDeprecated);
  275. end;
  276. procedure TTestConstParser.TestSimpleSetConstDeprecated;
  277. begin
  278. Hint:='deprecated';
  279. DoTestSimpleSetConst;
  280. CheckHint(hDeprecated);
  281. end;
  282. procedure TTestConstParser.TestSimpleExprConstDeprecated;
  283. begin
  284. Hint:='deprecated';
  285. DoTestSimpleExprConst;
  286. CheckHint(hDeprecated);
  287. end;
  288. procedure TTestConstParser.TestSimpleIntConstPlatform;
  289. begin
  290. Hint:='Platform';
  291. DoTestSimpleIntConst;
  292. CheckHint(hPlatform);
  293. end;
  294. procedure TTestConstParser.TestSimpleFloatConstPlatform;
  295. begin
  296. Hint:='Platform';
  297. DoTestSimpleIntConst;
  298. CheckHint(hPlatform);
  299. end;
  300. procedure TTestConstParser.TestSimpleStringConstPlatform;
  301. begin
  302. Hint:='Platform';
  303. DoTestSimpleStringConst;
  304. CheckHint(hPlatform);
  305. end;
  306. procedure TTestConstParser.TestSimpleNilConstPlatform;
  307. begin
  308. Hint:='Platform';
  309. DoTestSimpleNilConst;
  310. CheckHint(hPlatform);
  311. end;
  312. procedure TTestConstParser.TestSimpleBoolConstPlatform;
  313. begin
  314. Hint:='Platform';
  315. DoTestSimpleBoolConst;
  316. CheckHint(hPlatform);
  317. end;
  318. procedure TTestConstParser.TestSimpleIdentifierConstPlatform;
  319. begin
  320. Hint:='Platform';
  321. DoTestSimpleIdentifierConst;
  322. CheckHint(hPlatform);
  323. end;
  324. procedure TTestConstParser.TestSimpleExprConstPlatform;
  325. begin
  326. Hint:='Platform';
  327. DoTestSimpleExprConst;
  328. CheckHint(hPlatform);
  329. end;
  330. procedure TTestConstParser.TestSimpleSetConstPlatform;
  331. begin
  332. Hint:='Platform';
  333. DoTestSimpleSetConst;
  334. CheckHint(hPlatform);
  335. end;
  336. procedure TTestConstParser.TestSimpleIntConstExperimental;
  337. begin
  338. Hint:='Experimental';
  339. DoTestSimpleIntConst;
  340. CheckHint(hExperimental);
  341. end;
  342. procedure TTestConstParser.TestSimpleFloatConstExperimental;
  343. begin
  344. Hint:='Experimental';
  345. DoTestSimpleIntConst;
  346. CheckHint(hExperimental);
  347. end;
  348. procedure TTestConstParser.TestSimpleStringConstExperimental;
  349. begin
  350. Hint:='Experimental';
  351. DoTestSimpleStringConst;
  352. CheckHint(hExperimental);
  353. end;
  354. procedure TTestConstParser.TestSimpleNilConstExperimental;
  355. begin
  356. Hint:='Experimental';
  357. DoTestSimpleNilConst;
  358. CheckHint(hExperimental);
  359. end;
  360. procedure TTestConstParser.TestSimpleBoolConstExperimental;
  361. begin
  362. Hint:='Experimental';
  363. DoTestSimpleBoolConst;
  364. CheckHint(hExperimental);
  365. end;
  366. procedure TTestConstParser.TestSimpleIdentifierConstExperimental;
  367. begin
  368. Hint:='Experimental';
  369. DoTestSimpleIdentifierConst;
  370. CheckHint(hExperimental);
  371. end;
  372. procedure TTestConstParser.TestSimpleSetConstExperimental;
  373. begin
  374. Hint:='Experimental';
  375. DoTestSimpleSetConst;
  376. CheckHint(hExperimental);
  377. end;
  378. procedure TTestConstParser.TestSimpleExprConstExperimental;
  379. begin
  380. Hint:='Experimental';
  381. DoTestSimpleExprConst;
  382. CheckHint(hExperimental);
  383. end;
  384. procedure TTestConstParser.TestTypedIntConst;
  385. begin
  386. Typed:='Integer';
  387. DoTestSimpleIntConst
  388. end;
  389. procedure TTestConstParser.TestTypedFloatConst;
  390. begin
  391. Typed:='Double';
  392. DoTestSimpleFloatConst
  393. end;
  394. procedure TTestConstParser.TestTypedStringConst;
  395. begin
  396. Typed:='shortstring';
  397. DoTestSimpleStringConst
  398. end;
  399. procedure TTestConstParser.TestTypedNilConst;
  400. begin
  401. Typed:='PChar';
  402. DoTestSimpleNilConst
  403. end;
  404. procedure TTestConstParser.TestTypedBoolConst;
  405. begin
  406. Typed:='Boolean';
  407. DoTestSimpleBoolConst
  408. end;
  409. procedure TTestConstParser.TestTypedIdentifierConst;
  410. begin
  411. Typed:='TAlign';
  412. DoTestSimpleIdentifierConst
  413. end;
  414. procedure TTestConstParser.TestTypedSetConst;
  415. begin
  416. Typed:='TAligns';
  417. DoTestSimpleSetConst
  418. end;
  419. procedure TTestConstParser.TestTypedExprConst;
  420. begin
  421. Typed:='ShortInt';
  422. DoTestSimpleExprConst;
  423. end;
  424. procedure TTestConstParser.TestRecordConst;
  425. Var
  426. R : TRecordValues;
  427. Fi : TRecordValuesItem;
  428. begin
  429. Typed := 'TPoint';
  430. ParseConst('(x:1;y: 2)');
  431. AssertEquals('Record Values',TRecordValues,TheExpr.ClassType);
  432. R:=TheExpr as TRecordValues;
  433. AssertEquals('Expression list of ',pekListOfExp,TheExpr.Kind);
  434. AssertEquals('2 elements',2,Length(R.Fields));
  435. FI:=R.Fields[0];
  436. AssertEquals('Name field 1','x',Fi.Name);
  437. AssertExpression('Field 1 value',Fi.ValueExp,pekNumber,'1');
  438. FI:=R.Fields[1];
  439. AssertEquals('Name field 2','y',Fi.Name);
  440. AssertExpression('Field 2 value',Fi.ValueExp,pekNumber,'2');
  441. end;
  442. procedure TTestConstParser.TestArrayConst;
  443. Var
  444. R : TArrayValues;
  445. begin
  446. Typed := 'TMyArray';
  447. ParseConst('(1 , 2)');
  448. AssertEquals('Array Values',TArrayValues,TheExpr.ClassType);
  449. R:=TheExpr as TArrayValues;
  450. AssertEquals('Expression list of ',pekListOfExp,TheExpr.Kind);
  451. AssertEquals('2 elements',2,Length(R.Values));
  452. AssertExpression('Element 1 value',R.Values[0],pekNumber,'1');
  453. AssertExpression('Element 2 value',R.Values[1],pekNumber,'2');
  454. end;
  455. procedure TTestConstParser.TestRangeConst;
  456. begin
  457. Typed:='0..1';
  458. ParseConst('1');
  459. AssertEquals('Range type',TPasRangeType,TheConst.VarType.ClassType);
  460. AssertExpression('Float const', TheExpr,pekNumber,'1');
  461. end;
  462. procedure TTestConstParser.DoParseConstUnTypedRange;
  463. begin
  464. ParseConst('1..2');
  465. end;
  466. procedure TTestConstParser.TestRangeConstUnTyped;
  467. begin
  468. AssertException('Range const is not allowed',EParserError,@DoParseConstUnTypedRange);
  469. end;
  470. procedure TTestConstParser.TestArrayOfRangeConst;
  471. Var
  472. R : TArrayValues;
  473. begin
  474. Typed:='array [0..7] of 0..1';
  475. ParseConst('(0, 0, 0, 0, 0, 0, 0, 0)');
  476. AssertEquals('Array Values',TArrayValues,TheExpr.ClassType);
  477. R:=TheExpr as TArrayValues;
  478. AssertEquals('Expression list of ',pekListOfExp,TheExpr.Kind);
  479. AssertEquals('elements',8,Length(R.Values));
  480. // AssertEquals('Range type',TPasRangeType,TheConst.VarType.ClassType);
  481. // AssertExpression('Float const', TheExpr,pekNumber,'1');
  482. end;
  483. { TTestResourcestringParser }
  484. function TTestResourcestringParser.ParseResourcestring(ASource: String
  485. ): TPasResString;
  486. Var
  487. D : String;
  488. begin
  489. Add('Resourcestring');
  490. D:=' A = '+ASource;
  491. If Hint<>'' then
  492. D:=D+' '+Hint;
  493. Add(' '+D+';');
  494. Add('end.');
  495. //Writeln(source.text);
  496. ParseDeclarations;
  497. AssertEquals('One resourcestring definition',1,Declarations.ResStrings.Count);
  498. AssertEquals('First declaration is constant definition.',TPasResString,TObject(Declarations.ResStrings[0]).ClassType);
  499. Result:=TPasResString(Declarations.ResStrings[0]);
  500. FTheStr:=Result;
  501. FExpr:=Result.Expr;
  502. Definition:=Result;
  503. end;
  504. procedure TTestResourcestringParser.CheckExprNameKindClass(AKind: TPasExprKind;
  505. AClass: TClass);
  506. begin
  507. AssertEquals('Correct name','A',TheStr.Name);
  508. AssertEquals('Correct expression kind',aKind,TheExpr.Kind);
  509. AssertEquals('Correct expression class',AClass,TheExpr.ClassType);
  510. // Writeln('Delcaration : ',TheStr.GetDeclaration(True));
  511. end;
  512. procedure TTestResourcestringParser.DoTestSimple;
  513. begin
  514. ParseResourcestring('''Something''');
  515. CheckExprNameKindClass(pekString,TPrimitiveExpr);
  516. AssertEquals('Correct expression value','''Something''',TPrimitiveExpr(TheExpr).Value);
  517. end;
  518. procedure TTestResourcestringParser.DoTestSum;
  519. var
  520. B: TBinaryExpr;
  521. begin
  522. ParseResourcestring('''Something''+'' else''');
  523. CheckExprNameKindClass(pekBinary,TBinaryExpr);
  524. B:=TBinaryExpr(TheExpr);
  525. TAssert.AssertSame('B.left.parent=B',B,B.left.Parent);
  526. TAssert.AssertSame('B.right.parent=B',B,B.right.Parent);
  527. AssertEquals('Correct left',TPrimitiveExpr,B.Left.ClassType);
  528. AssertEquals('Correct right',TPrimitiveExpr,B.Right.ClassType);
  529. AssertEquals('Correct left expression value','''Something''',TPrimitiveExpr(B.Left).Value);
  530. AssertEquals('Correct right expression value',''' else''',TPrimitiveExpr(B.Right).Value);
  531. end;
  532. procedure TTestResourcestringParser.DoTestSum2;
  533. var
  534. B: TBinaryExpr;
  535. begin
  536. ParseResourcestring('''Something''+different');
  537. CheckExprNameKindClass(pekBinary,TBinaryExpr);
  538. B:=TBinaryExpr(TheExpr);
  539. TAssert.AssertSame('B.left.parent=B',B,B.left.Parent);
  540. TAssert.AssertSame('B.right.parent=B',B,B.right.Parent);
  541. AssertEquals('Correct left',TPrimitiveExpr,B.Left.ClassType);
  542. AssertEquals('Correct right',TPrimitiveExpr,B.Right.ClassType);
  543. AssertEquals('Correct left expression value','''Something''',TPrimitiveExpr(B.Left).Value);
  544. AssertEquals('Correct right expression value','different',TPrimitiveExpr(B.Right).Value);
  545. end;
  546. procedure TTestResourcestringParser.TestSimple;
  547. begin
  548. DoTestSimple;
  549. end;
  550. procedure TTestResourcestringParser.TestSimpleDeprecated;
  551. begin
  552. Hint:='deprecated';
  553. DoTestSimple;
  554. CheckHint(hDeprecated);
  555. end;
  556. procedure TTestResourcestringParser.TestSimplePlatform;
  557. begin
  558. Hint:='platform';
  559. DoTestSimple;
  560. CheckHint(hPlatform);
  561. end;
  562. procedure TTestResourcestringParser.TestSum2;
  563. begin
  564. DoTestSum2;
  565. end;
  566. procedure TTestResourcestringParser.TestSum2Deprecated;
  567. begin
  568. Hint:='deprecated';
  569. DoTestSum2;
  570. CheckHint(hDeprecated);
  571. end;
  572. procedure TTestResourcestringParser.TestSum2Platform;
  573. begin
  574. Hint:='platform';
  575. DoTestSum2;
  576. CheckHint(hplatform);
  577. end;
  578. procedure TTestResourcestringParser.TestSum1;
  579. begin
  580. DoTestSum;
  581. end;
  582. procedure TTestResourcestringParser.TestSum1Deprecated;
  583. begin
  584. Hint:='deprecated';
  585. DoTestSum;
  586. CheckHint(hDeprecated);
  587. end;
  588. procedure TTestResourcestringParser.TestSum1Platform;
  589. begin
  590. Hint:='platform';
  591. DoTestSum;
  592. CheckHint(hplatform);
  593. end;
  594. initialization
  595. RegisterTests([TTestConstParser,TTestResourcestringParser]);
  596. end.