github.com/solo-io/cue@v0.4.7/cue/testdata/builtins/intdiv.txtar (about)

     1  -- in.cue --
     2  quo1:  quo(5, 2)   // 2
     3  quo2:  quo(5, -2)  // -2
     4  quo3:  quo(-5, 2)  // -2
     5  quo4:  quo(-5, -2) // 2
     6  
     7  quoDivByZero: quo(2, 0)
     8  
     9  quoTypeError1: quo(2.0, 1)
    10  quoTypeError2: quo(2, 1.0)
    11  
    12  
    13  rem1:  rem(5, 2)   // 1
    14  rem2:  rem(5, -2)  // 1
    15  rem3:  rem(-5, 2)  // -1
    16  rem4:  rem(-5, -2) // -1
    17  
    18  remDivByZero: rem(2, 0)
    19  
    20  remTypeError1: rem(2.0, 1)
    21  remTypeError2: rem(2, 1.0)
    22  
    23  
    24  div1:  div(5, 2)   // 2
    25  div2:  div(5, -2)  // -2
    26  div3:  div(-5, 2)  // -3
    27  div4:  div(-5, -2) // 3
    28  
    29  divDivByZero: div(2, 0)
    30  
    31  divTypeError1: div(2.0, 1)
    32  divTypeError2: div(2, 1.0)
    33  
    34  
    35  mod1:  mod(5, 2)   // 1
    36  mod2:  mod(5, -2)  // 1
    37  mod3:  mod(-5, 2)  // 1
    38  mod4:  mod(-5, -2) // 1
    39  
    40  modDivByZero: mod(2, 0)
    41  
    42  modTypeError1: mod(2.0, 1)
    43  modTypeError2: mod(2, 1.0)
    44  
    45  -- out/eval --
    46  Errors:
    47  quoDivByZero: division by zero:
    48      ./in.cue:6:15
    49  quoTypeError1: cannot use 2.0 (type float) as int in argument 1 to quo:
    50      ./in.cue:8:20
    51  quoTypeError2: cannot use 1.0 (type float) as int in argument 2 to quo:
    52      ./in.cue:9:23
    53  remDivByZero: division by zero:
    54      ./in.cue:17:15
    55  remTypeError1: cannot use 2.0 (type float) as int in argument 1 to rem:
    56      ./in.cue:19:20
    57  remTypeError2: cannot use 1.0 (type float) as int in argument 2 to rem:
    58      ./in.cue:20:23
    59  divDivByZero: division by zero:
    60      ./in.cue:28:15
    61  divTypeError1: cannot use 2.0 (type float) as int in argument 1 to div:
    62      ./in.cue:30:20
    63  divTypeError2: cannot use 1.0 (type float) as int in argument 2 to div:
    64      ./in.cue:31:23
    65  modDivByZero: division by zero:
    66      ./in.cue:39:15
    67  modTypeError1: cannot use 2.0 (type float) as int in argument 1 to mod:
    68      ./in.cue:41:20
    69  modTypeError2: cannot use 1.0 (type float) as int in argument 2 to mod:
    70      ./in.cue:42:23
    71  
    72  Result:
    73  (_|_){
    74    // [eval]
    75    quo1: (int){ 2 }
    76    quo2: (int){ -2 }
    77    quo3: (int){ -2 }
    78    quo4: (int){ 2 }
    79    quoDivByZero: (_|_){
    80      // [eval] quoDivByZero: division by zero:
    81      //     ./in.cue:6:15
    82    }
    83    quoTypeError1: (_|_){
    84      // [eval] quoTypeError1: cannot use 2.0 (type float) as int in argument 1 to quo:
    85      //     ./in.cue:8:20
    86    }
    87    quoTypeError2: (_|_){
    88      // [eval] quoTypeError2: cannot use 1.0 (type float) as int in argument 2 to quo:
    89      //     ./in.cue:9:23
    90    }
    91    rem1: (int){ 1 }
    92    rem2: (int){ 1 }
    93    rem3: (int){ -1 }
    94    rem4: (int){ -1 }
    95    remDivByZero: (_|_){
    96      // [eval] remDivByZero: division by zero:
    97      //     ./in.cue:17:15
    98    }
    99    remTypeError1: (_|_){
   100      // [eval] remTypeError1: cannot use 2.0 (type float) as int in argument 1 to rem:
   101      //     ./in.cue:19:20
   102    }
   103    remTypeError2: (_|_){
   104      // [eval] remTypeError2: cannot use 1.0 (type float) as int in argument 2 to rem:
   105      //     ./in.cue:20:23
   106    }
   107    div1: (int){ 2 }
   108    div2: (int){ -2 }
   109    div3: (int){ -3 }
   110    div4: (int){ 3 }
   111    divDivByZero: (_|_){
   112      // [eval] divDivByZero: division by zero:
   113      //     ./in.cue:28:15
   114    }
   115    divTypeError1: (_|_){
   116      // [eval] divTypeError1: cannot use 2.0 (type float) as int in argument 1 to div:
   117      //     ./in.cue:30:20
   118    }
   119    divTypeError2: (_|_){
   120      // [eval] divTypeError2: cannot use 1.0 (type float) as int in argument 2 to div:
   121      //     ./in.cue:31:23
   122    }
   123    mod1: (int){ 1 }
   124    mod2: (int){ 1 }
   125    mod3: (int){ 1 }
   126    mod4: (int){ 1 }
   127    modDivByZero: (_|_){
   128      // [eval] modDivByZero: division by zero:
   129      //     ./in.cue:39:15
   130    }
   131    modTypeError1: (_|_){
   132      // [eval] modTypeError1: cannot use 2.0 (type float) as int in argument 1 to mod:
   133      //     ./in.cue:41:20
   134    }
   135    modTypeError2: (_|_){
   136      // [eval] modTypeError2: cannot use 1.0 (type float) as int in argument 2 to mod:
   137      //     ./in.cue:42:23
   138    }
   139  }
   140  -- out/compile --
   141  --- in.cue
   142  {
   143    quo1: quo(5, 2)
   144    quo2: quo(5, -2)
   145    quo3: quo(-5, 2)
   146    quo4: quo(-5, -2)
   147    quoDivByZero: quo(2, 0)
   148    quoTypeError1: quo(2.0, 1)
   149    quoTypeError2: quo(2, 1.0)
   150    rem1: rem(5, 2)
   151    rem2: rem(5, -2)
   152    rem3: rem(-5, 2)
   153    rem4: rem(-5, -2)
   154    remDivByZero: rem(2, 0)
   155    remTypeError1: rem(2.0, 1)
   156    remTypeError2: rem(2, 1.0)
   157    div1: div(5, 2)
   158    div2: div(5, -2)
   159    div3: div(-5, 2)
   160    div4: div(-5, -2)
   161    divDivByZero: div(2, 0)
   162    divTypeError1: div(2.0, 1)
   163    divTypeError2: div(2, 1.0)
   164    mod1: mod(5, 2)
   165    mod2: mod(5, -2)
   166    mod3: mod(-5, 2)
   167    mod4: mod(-5, -2)
   168    modDivByZero: mod(2, 0)
   169    modTypeError1: mod(2.0, 1)
   170    modTypeError2: mod(2, 1.0)
   171  }