source: to-imperative/trunk/samples/Arithm/gcd.cc @ 1056

Last change on this file since 1056 was 1056, checked in by luba, 18 years ago
  • tests for GCD and Div-Rem functions
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.1 KB
Line 
1#include <rf_core.hh>
2#include <refal/StdIO.hh>
3#include <refal/Arithm.hh>
4
5namespace refal
6{
7
8using namespace rfrt;
9
10namespace gcd
11{
12
13static const Expr _c_0 = ShortInt::create_expr (22);
14
15static const Expr _c_1 = ShortInt::create_expr (2);
16
17static const Expr _c_2 = Integer::create_expr ("2147483648");
18
19static const Expr _c_3 = ShortInt::create_expr (135);
20
21static const Expr _c_4 = ShortInt::create_expr (-1146);
22
23static const Expr _c_5 = ShortInt::create_expr (-1245);
24
25static const Expr _c_6 = ShortInt::create_expr (-1156);
26
27static const Expr _c_7 = Integer::create_expr ("-2147483648");
28
29static const Expr _c_8 = ShortInt::create_expr (-1156548745);
30
31static const Expr _c_9 = Integer::create_expr ("-1156548745234678");
32
33static const Expr _c_10 = Integer::create_expr ("214748364809876");
34
35static const Expr _c_11 = ShortInt::create_expr (2147483647);
36
37static const Expr _c_12 = ShortInt::create_expr (-2147483647);
38
39RF_FUNC (Main, (), (RF_RES _v_res1))
40  {
41    Expr _v_GCD1;
42    RF_CALL (Arithm::GCD, (_c_0, _c_1), (_v_GCD1));
43    RF_CALL (StdIO::PrintLN, (_v_GCD1), ());
44    Expr _v_GCD2;
45    RF_CALL (Arithm::GCD, (_c_2, _c_3), (_v_GCD2));
46    RF_CALL (StdIO::PrintLN, (_v_GCD2), ());
47    Expr _v_GCD3;
48    RF_CALL (Arithm::GCD, (_c_2, _c_4), (_v_GCD3));
49    RF_CALL (StdIO::PrintLN, (_v_GCD3), ());
50    Expr _v_GCD4;
51    RF_CALL (Arithm::GCD, (_c_5, _c_2), (_v_GCD4));
52    RF_CALL (StdIO::PrintLN, (_v_GCD4), ());
53    Expr _v_GCD5;
54    RF_CALL (Arithm::GCD, (_c_6, _c_7), (_v_GCD5));
55    RF_CALL (StdIO::PrintLN, (_v_GCD5), ());
56    Expr _v_GCD6;
57    RF_CALL (Arithm::GCD, (_c_8, _c_7), (_v_GCD6));
58    RF_CALL (StdIO::PrintLN, (_v_GCD6), ());
59    Expr _v_GCD7;
60    RF_CALL (Arithm::GCD, (_c_9, _c_10), (_v_GCD7));
61    RF_CALL (StdIO::PrintLN, (_v_GCD7), ());
62    Expr _v_GCD8;
63    RF_CALL (Arithm::GCD, (_c_11, _c_12), (_v_GCD8));
64    RF_CALL (StdIO::PrintLN, (_v_GCD8), ());
65    Expr _v_GCD9;
66    RF_CALL (Arithm::GCD, (_c_7, _c_2), (_v_GCD9));
67    RF_CALL (StdIO::PrintLN, (_v_GCD9), ());
68    Expr _v_GCD10;
69    RF_CALL (Arithm::GCD, (_c_2, _c_2), (_v_GCD10));
70    RF_CALL (StdIO::PrintLN, (_v_GCD10), ());
71    _v_res1 = empty;
72  }
73RF_END
74
75}
76
77rfrt::Entry rf_entry (gcd::Main);
78
79}
Note: See TracBrowser for help on using the repository browser.