Ignore:
Timestamp:
May 15, 2017, 3:27:47 PM (7 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
db0fa7c
Parents:
dbfb35d (diff), 9ff8310 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tests/rational.c

    rdbfb35d r3bd1eb4  
    1010// Created On       : Mon Mar 28 08:43:12 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue May  2 22:11:05 2017
    13 // Update Count     : 41
     12// Last Modified On : Sun May 14 18:10:28 2017
     13// Update Count     : 57
    1414//
    1515
     16#include <rational>
    1617#include <limits>
    17 #include <rational>
     18#include <stdlib>
    1819#include <fstream>
     20
     21// UNNECESSARY, FIX ME
     22void ?{}( int * this ) { *this = 0; }
     23void ?{}( int * this, zero_t ) { *this = 0; }
     24void ?{}( int * this, one_t ) { *this = 1; }
    1925
    2026int main() {
    2127        sout | "constructor" | endl;
    22         Rational a = { 3 }, b = { 4 }, c;
     28        Rational(int) a = { 3 }, b = { 4 }, c;
    2329        sout | a | b | c | endl;
    24         a = (Rational){ 4, 8 };
    25         b = (Rational){ 5, 7 };
     30
     31        a = (Rational(int)){ 4, 8 };
     32        b = (Rational(int)){ 5, 7 };
    2633        sout | a | b | endl;
    27         a = (Rational){ -2, -3 };
    28         b = (Rational){ 3, -2 };
     34        a = (Rational(int)){ -2, -3 };
     35        b = (Rational(int)){ 3, -2 };
    2936        sout | a | b | endl;
    30         a = (Rational){ -2, 3 };
    31         b = (Rational){ 3, 2 };
     37        a = (Rational(int)){ -2, 3 };
     38        b = (Rational(int)){ 3, 2 };
    3239        sout | a | b | endl;
    3340
    3441        sout | "logical" | endl;
    35         a = (Rational){ -2 };
    36         b = (Rational){ -3, 2 };
     42        a = (Rational(int)){ -2 };
     43        b = (Rational(int)){ -3, 2 };
    3744        sout | a | b | endl;
    3845//      sout | a == 1 | endl; // FIX ME
     
    5057        sout | a / b | endl;
    5158
    52         sout | "conversion" | endl;
    53         a = (Rational){ 3, 4 };
    54         sout | widen( a ) | endl;
    55         a = (Rational){ 1, 7 };
    56         sout | widen( a ) | endl;
    57         a = (Rational){ 355, 113 };
    58         sout | widen( a ) | endl;
    59         sout | narrow( 0.75, 4 ) | endl;
    60         sout | narrow( 0.14285714285714, 16 ) | endl;
    61         sout | narrow( 3.14159265358979, 256 ) | endl;
     59//      sout | "conversion" | endl;
     60//      a = (Rational(int)){ 3, 4 };
     61//      sout | widen( a ) | endl;
     62//      a = (Rational(int)){ 1, 7 };
     63//      sout | widen( a ) | endl;
     64//      a = (Rational(int)){ 355, 113 };
     65//      sout | widen( a ) | endl;
     66//      sout | narrow( 0.75, 4 ) | endl;
     67//      sout | narrow( 0.14285714285714, 16 ) | endl;
     68//      sout | narrow( 3.14159265358979, 256 ) | endl;
    6269
    6370        sout | "decompose" | endl;
    64         RationalImpl n, d;
     71        int n, d;
    6572//      [n, d] = a;
    6673//      sout | a | n | d | endl;
    6774
    6875        sout | "more tests" | endl;
    69         Rational x = { 1, 2 }, y = { 2 };
     76        Rational(int) x = { 1, 2 }, y = { 2 };
    7077        sout | x - y | endl;
    7178        sout | x > y | endl;
     
    7380        sout | y | denominator( y, -2 ) | y | endl;
    7481
    75         Rational z = { 0, 5 };
     82        Rational(int) z = { 0, 5 };
    7683        sout | z | endl;
    7784
    7885        sout | x | numerator( x, 0 ) | x | endl;
    7986
    80         x = (Rational){ 1, MAX } + (Rational){ 1, MAX };
     87        x = (Rational(int)){ 1, MAX } + (Rational(int)){ 1, MAX };
    8188        sout | x | endl;
    82         x = (Rational){ 3, MAX } + (Rational){ 2, MAX };
     89        x = (Rational(int)){ 3, MAX } + (Rational(int)){ 2, MAX };
    8390        sout | x | endl;
    8491
Note: See TracChangeset for help on using the changeset viewer.