Development

Changeset 20694

You must first sign up to be able to contribute.

Changeset 20694

Show
Ignore:
Timestamp:
08/02/09 15:25:19 (5 years ago)
Author:
bschussek
Message:

Refactored assertEquals($expected, $strict) to assertEquals() and assertSame()

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • tools/lime/branches/2.0-experimental/lib/tester/LimeTester.php

    r20499 r20694  
    115115  } 
    116116 
    117   public function assertEquals($expected, $strict = false
     117  public function assertEquals($expected
    118118  { 
    119119    $this->notImplemented('=='); 
    120120  } 
    121121 
    122   public function assertNotEquals($expected, $strict = false
     122  public function assertNotEquals($expected
    123123  { 
    124124    $this->notImplemented('!='); 
     125  } 
     126 
     127  public function assertSame($expected) 
     128  { 
     129    $this->notImplemented('==='); 
     130  } 
     131 
     132  public function assertNotSame($expected) 
     133  { 
     134    $this->notImplemented('!=='); 
    125135  } 
    126136 
  • tools/lime/branches/2.0-experimental/lib/tester/LimeTesterArray.php

    r20500 r20694  
    2525  } 
    2626 
    27   public function assertEquals($expected, $strict = false
     27  public function assertEquals($expected
    2828  { 
    2929    if (!$expected instanceof LimeTesterArray || $this->getType() !== $expected->getType()) 
     
    4343      try 
    4444      { 
    45         $remaining[$key]->assertEquals($value, $strict); 
     45        $remaining[$key]->assertEquals($value); 
    4646      } 
    4747      catch (LimeNotEqualException $e) 
     
    5959  } 
    6060 
    61   public function assertNotEquals($expected, $strict = false
     61  public function assertNotEquals($expected
    6262  { 
    6363    if (!$expected instanceof LimeTesterArray || $this->getType() !== $expected->getType()) 
     
    7575      try 
    7676      { 
    77         $this->value[$key]->assertNotEquals($value, $strict); 
     77        $this->value[$key]->assertNotEquals($value); 
    7878      } 
    7979      catch (LimeNotEqualException $e) 
  • tools/lime/branches/2.0-experimental/lib/tester/LimeTesterDouble.php

    r20499 r20694  
    3535  } 
    3636 
    37   public function assertEquals($expected, $strict = false
     37  public function assertEquals($expected
    3838  { 
    39     $equal = abs($this->value - $expected->value) < self::EPSILON; 
    40  
    41     if (!$equal || ($strict && gettype($this->value) != gettype($expected->value))) 
     39    if (abs($this->value - $expected->value) >= self::EPSILON) 
    4240    { 
    4341      throw new LimeNotEqualException($this, $expected); 
     
    4543  } 
    4644 
    47   public function assertNotEquals($expected, $strict = false
     45  public function assertNotEquals($expected
    4846  { 
    49     $equal = abs($this->value - $expected->value) < self::EPSILON; 
    50  
    51     if ($equal && (!$strict || gettype($this->value) == gettype($expected->value))) 
     47    if (abs($this->value - $expected->value) < self::EPSILON) 
    5248    { 
    5349      throw new LimeNotEqualException($this, $expected); 
    5450    } 
    5551  } 
     52 
     53  public function assertSame($expected) 
     54  { 
     55    $this->assertEquals($expected); 
     56 
     57    if (gettype($this->value) != gettype($expected->value)) 
     58    { 
     59      throw new LimeNotEqualException($this, $expected); 
     60    } 
     61  } 
     62 
     63  public function assertNotSame($expected) 
     64  { 
     65    try 
     66    { 
     67      $this->assertEquals($expected); 
     68    } 
     69    catch (LimeNotEqualException $e) 
     70    { 
     71      if (gettype($this->value) == gettype($expected->value)) 
     72      { 
     73        throw $e; 
     74      } 
     75    } 
     76  } 
    5677} 
  • tools/lime/branches/2.0-experimental/lib/tester/LimeTesterInterface.php

    r20499 r20694  
    1414  public function __toString(); 
    1515 
    16   public function assertEquals($expected, $strict = false); 
     16  public function assertEquals($expected); 
    1717 
    18   public function assertNotEquals($expected, $strict = false); 
     18  public function assertNotEquals($expected); 
     19 
     20  public function assertSame($expected); 
     21 
     22  public function assertNotSame($expected); 
    1923 
    2024  public function assertLike($expected); 
  • tools/lime/branches/2.0-experimental/lib/tester/LimeTesterObject.php

    r20693 r20694  
    6060  } 
    6161 
    62   public function assertEquals($expected, $strict = false
     62  public function assertSame($expected
    6363  { 
    64     parent::assertEquals($expected, $strict); 
     64    $this->assertEquals($expected); 
    6565 
    6666    // still no exceptions, so properties are the same 
    67     if ($strict && $this->object !== $expected->object) 
     67    if ($this->object !== $expected->object) 
    6868    { 
    6969      throw new LimeNotEqualException($this, $expected); 
     
    7171  } 
    7272 
    73   public function assertNotEquals($expected, $strict = false
     73  public function assertNotSame($expected
    7474  { 
    7575    try 
    7676    { 
    77       parent::assertNotEquals($expected, $strict); 
     77      $this->assertNotEquals($expected); 
    7878    } 
    7979    catch (LimeNotEqualException $e) 
    8080    { 
    81       if (!$strict || $this->object === $expected->object) 
     81      if ($this->object === $expected->object) 
    8282      { 
    8383        throw $e; 
  • tools/lime/branches/2.0-experimental/lib/tester/LimeTesterResource.php

    r20499 r20694  
    1515    $type = 'resource'; 
    1616 
    17   public function assertEquals($expected, $strict = false
     17  public function assertEquals($expected
    1818  { 
    1919  } 
  • tools/lime/branches/2.0-experimental/lib/tester/LimeTesterScalar.php

    r20499 r20694  
    2727  } 
    2828 
    29   public function assertEquals($expected, $strict = false
     29  public function assertEquals($expected
    3030  { 
    31     $equal = $strict ? $this->value === $expected->value : $this->value == $expected->value; 
    32  
    33     if (!$equal) 
     31    if ($this->value != $expected->value) 
    3432    { 
    3533      throw new LimeNotEqualException($this, $expected); 
     
    3735  } 
    3836 
    39   public function assertNotEquals($expected, $strict = false
     37  public function assertSame($expected
    4038  { 
    41     $equal = $strict ? $this->value === $expected->value : $this->value == $expected->value; 
     39    if ($this->value !== $expected->value) 
     40    { 
     41      throw new LimeNotEqualException($this, $expected); 
     42    } 
     43  } 
    4244 
    43     if ($equal) 
     45  public function assertNotEquals($expected) 
     46  { 
     47    if ($this->value == $expected->value) 
     48    { 
     49      throw new LimeNotEqualException($this, $expected); 
     50    } 
     51  } 
     52 
     53  public function assertNotSame($expected) 
     54  { 
     55    if ($this->value === $expected->value) 
    4456    { 
    4557      throw new LimeNotEqualException($this, $expected); 
  • tools/lime/branches/2.0-experimental/test/unit/tester/LimeTesterDoubleTest.php

    r20499 r20694  
    3232 
    3333 
    34 // @Test: assertEquals() throws an exception if the types of the values differ and strict is set 
     34// @Test: assertSame() throws an exception if the types of the values differ 
    3535 
    3636  // fixtures 
     
    3939  // test 
    4040  $t->expect('LimeNotEqualException'); 
    41   $actual->assertEquals($expected, true); 
     41  $actual->assertSame($expected); 
    4242 
    4343 
     
    5252 
    5353 
    54 // @Test: assertNotEquals() throws no exception if the types of the values differ and strict is set 
     54// @Test: assertNotSame() throws no exception if the types of the values differ 
    5555 
    5656  // fixtures 
     
    5858  $expected = new LimeTesterString('1.0'); 
    5959  // test 
    60   $actual->assertNotEquals($expected, true); 
     60  $actual->assertNotSame($expected); 
    6161 
  • tools/lime/branches/2.0-experimental/test/unit/tester/LimeTesterObjectTest.php

    r20500 r20694  
    5858 
    5959 
    60 // @Test: assertEquals() throws an exception if objects are not the same and strict is set 
     60// @Test: assertSame() throws an exception if objects are not the same 
    6161 
    6262  // fixtures 
     
    6565  // test 
    6666  $t->expect('LimeNotEqualException'); 
    67   $actual->assertEquals($expected, true); 
     67  $actual->assertSame($expected); 
    6868 
    6969 
     
    9797 
    9898 
    99 // @Test: assertNotEquals() throws an exception if the objects are identical and strict is set 
     99// @Test: assertNotSame() throws an exception if the objects are identical and strict is set 
    100100 
    101101  // fixtures 
     
    105105  // test 
    106106  $t->expect('LimeNotEqualException'); 
    107   $actual->assertNotEquals($expected, true); 
     107  $actual->assertNotSame($expected); 
    108108 
    109109 
    110 // @Test: assertNotEquals() throws no exception if the objects are equal but strict is set 
     110// @Test: assertNotSame() throws no exception if the objects are equal but strict is set 
    111111 
    112112  // fixtures 
     
    114114  $expected = new LimeTesterObject(new TestClass()); 
    115115  // test 
    116   $actual->assertNotEquals($expected, true); 
     116  $actual->assertNotSame($expected); 
    117117 
  • tools/lime/branches/2.0-experimental/test/unit/tester/LimeTesterScalarTest.php

    r20499 r20694  
    3636 
    3737 
    38 // @Test: assertEquals() throws an exception if the values have different types and strict is set 
     38// @Test: assertSame() throws an exception if the values have different types 
    3939 
    4040  // fixtures 
     
    4343  // test 
    4444  $t->expect('LimeNotEqualException'); 
    45   $actual->assertEquals($expected, true); 
     45  $actual->assertSame($expected); 
    4646 
    4747 
     
    5656 
    5757 
    58 // @Test: assertNotEquals() throws no exception if values are equal but types are different and strict is se
     58// @Test: assertNotSame() throws no exception if values are equal but types are differen
    5959 
    6060  // fixtures 
     
    6262  $expected = new LimeTesterScalar(1); 
    6363  // test 
    64   $actual->assertNotEquals($expected, true); 
     64  $actual->assertNotSame($expected);