Changeset 20694
- Timestamp:
- 08/02/09 15:25:19 (4 years ago)
- Files:
-
- tools/lime/branches/2.0-experimental/lib/tester/LimeTester.php (modified) (1 diff)
- tools/lime/branches/2.0-experimental/lib/tester/LimeTesterArray.php (modified) (4 diffs)
- tools/lime/branches/2.0-experimental/lib/tester/LimeTesterDouble.php (modified) (2 diffs)
- tools/lime/branches/2.0-experimental/lib/tester/LimeTesterInterface.php (modified) (1 diff)
- tools/lime/branches/2.0-experimental/lib/tester/LimeTesterObject.php (modified) (2 diffs)
- tools/lime/branches/2.0-experimental/lib/tester/LimeTesterResource.php (modified) (1 diff)
- tools/lime/branches/2.0-experimental/lib/tester/LimeTesterScalar.php (modified) (2 diffs)
- tools/lime/branches/2.0-experimental/test/unit/tester/LimeTesterDoubleTest.php (modified) (4 diffs)
- tools/lime/branches/2.0-experimental/test/unit/tester/LimeTesterObjectTest.php (modified) (5 diffs)
- tools/lime/branches/2.0-experimental/test/unit/tester/LimeTesterScalarTest.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
tools/lime/branches/2.0-experimental/lib/tester/LimeTester.php
r20499 r20694 115 115 } 116 116 117 public function assertEquals($expected , $strict = false)117 public function assertEquals($expected) 118 118 { 119 119 $this->notImplemented('=='); 120 120 } 121 121 122 public function assertNotEquals($expected , $strict = false)122 public function assertNotEquals($expected) 123 123 { 124 124 $this->notImplemented('!='); 125 } 126 127 public function assertSame($expected) 128 { 129 $this->notImplemented('==='); 130 } 131 132 public function assertNotSame($expected) 133 { 134 $this->notImplemented('!=='); 125 135 } 126 136 tools/lime/branches/2.0-experimental/lib/tester/LimeTesterArray.php
r20500 r20694 25 25 } 26 26 27 public function assertEquals($expected , $strict = false)27 public function assertEquals($expected) 28 28 { 29 29 if (!$expected instanceof LimeTesterArray || $this->getType() !== $expected->getType()) … … 43 43 try 44 44 { 45 $remaining[$key]->assertEquals($value , $strict);45 $remaining[$key]->assertEquals($value); 46 46 } 47 47 catch (LimeNotEqualException $e) … … 59 59 } 60 60 61 public function assertNotEquals($expected , $strict = false)61 public function assertNotEquals($expected) 62 62 { 63 63 if (!$expected instanceof LimeTesterArray || $this->getType() !== $expected->getType()) … … 75 75 try 76 76 { 77 $this->value[$key]->assertNotEquals($value , $strict);77 $this->value[$key]->assertNotEquals($value); 78 78 } 79 79 catch (LimeNotEqualException $e) tools/lime/branches/2.0-experimental/lib/tester/LimeTesterDouble.php
r20499 r20694 35 35 } 36 36 37 public function assertEquals($expected , $strict = false)37 public function assertEquals($expected) 38 38 { 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) 42 40 { 43 41 throw new LimeNotEqualException($this, $expected); … … 45 43 } 46 44 47 public function assertNotEquals($expected , $strict = false)45 public function assertNotEquals($expected) 48 46 { 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) 52 48 { 53 49 throw new LimeNotEqualException($this, $expected); 54 50 } 55 51 } 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 } 56 77 } tools/lime/branches/2.0-experimental/lib/tester/LimeTesterInterface.php
r20499 r20694 14 14 public function __toString(); 15 15 16 public function assertEquals($expected , $strict = false);16 public function assertEquals($expected); 17 17 18 public function assertNotEquals($expected, $strict = false); 18 public function assertNotEquals($expected); 19 20 public function assertSame($expected); 21 22 public function assertNotSame($expected); 19 23 20 24 public function assertLike($expected); tools/lime/branches/2.0-experimental/lib/tester/LimeTesterObject.php
r20693 r20694 60 60 } 61 61 62 public function assert Equals($expected, $strict = false)62 public function assertSame($expected) 63 63 { 64 parent::assertEquals($expected, $strict);64 $this->assertEquals($expected); 65 65 66 66 // still no exceptions, so properties are the same 67 if ($ strict && $this->object !== $expected->object)67 if ($this->object !== $expected->object) 68 68 { 69 69 throw new LimeNotEqualException($this, $expected); … … 71 71 } 72 72 73 public function assertNot Equals($expected, $strict = false)73 public function assertNotSame($expected) 74 74 { 75 75 try 76 76 { 77 parent::assertNotEquals($expected, $strict);77 $this->assertNotEquals($expected); 78 78 } 79 79 catch (LimeNotEqualException $e) 80 80 { 81 if ( !$strict ||$this->object === $expected->object)81 if ($this->object === $expected->object) 82 82 { 83 83 throw $e; tools/lime/branches/2.0-experimental/lib/tester/LimeTesterResource.php
r20499 r20694 15 15 $type = 'resource'; 16 16 17 public function assertEquals($expected , $strict = false)17 public function assertEquals($expected) 18 18 { 19 19 } tools/lime/branches/2.0-experimental/lib/tester/LimeTesterScalar.php
r20499 r20694 27 27 } 28 28 29 public function assertEquals($expected , $strict = false)29 public function assertEquals($expected) 30 30 { 31 $equal = $strict ? $this->value === $expected->value : $this->value == $expected->value; 32 33 if (!$equal) 31 if ($this->value != $expected->value) 34 32 { 35 33 throw new LimeNotEqualException($this, $expected); … … 37 35 } 38 36 39 public function assert NotEquals($expected, $strict = false)37 public function assertSame($expected) 40 38 { 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 } 42 44 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) 44 56 { 45 57 throw new LimeNotEqualException($this, $expected); tools/lime/branches/2.0-experimental/test/unit/tester/LimeTesterDoubleTest.php
r20499 r20694 32 32 33 33 34 // @Test: assert Equals() throws an exception if the types of the values differ and strict is set34 // @Test: assertSame() throws an exception if the types of the values differ 35 35 36 36 // fixtures … … 39 39 // test 40 40 $t->expect('LimeNotEqualException'); 41 $actual->assert Equals($expected, true);41 $actual->assertSame($expected); 42 42 43 43 … … 52 52 53 53 54 // @Test: assertNot Equals() throws no exception if the types of the values differ and strict is set54 // @Test: assertNotSame() throws no exception if the types of the values differ 55 55 56 56 // fixtures … … 58 58 $expected = new LimeTesterString('1.0'); 59 59 // test 60 $actual->assertNot Equals($expected, true);60 $actual->assertNotSame($expected); 61 61 tools/lime/branches/2.0-experimental/test/unit/tester/LimeTesterObjectTest.php
r20500 r20694 58 58 59 59 60 // @Test: assert Equals() throws an exception if objects are not the same and strict is set60 // @Test: assertSame() throws an exception if objects are not the same 61 61 62 62 // fixtures … … 65 65 // test 66 66 $t->expect('LimeNotEqualException'); 67 $actual->assert Equals($expected, true);67 $actual->assertSame($expected); 68 68 69 69 … … 97 97 98 98 99 // @Test: assertNot Equals() throws an exception if the objects are identical and strict is set99 // @Test: assertNotSame() throws an exception if the objects are identical and strict is set 100 100 101 101 // fixtures … … 105 105 // test 106 106 $t->expect('LimeNotEqualException'); 107 $actual->assertNot Equals($expected, true);107 $actual->assertNotSame($expected); 108 108 109 109 110 // @Test: assertNot Equals() throws no exception if the objects are equal but strict is set110 // @Test: assertNotSame() throws no exception if the objects are equal but strict is set 111 111 112 112 // fixtures … … 114 114 $expected = new LimeTesterObject(new TestClass()); 115 115 // test 116 $actual->assertNot Equals($expected, true);116 $actual->assertNotSame($expected); 117 117 tools/lime/branches/2.0-experimental/test/unit/tester/LimeTesterScalarTest.php
r20499 r20694 36 36 37 37 38 // @Test: assert Equals() throws an exception if the values have different types and strict is set38 // @Test: assertSame() throws an exception if the values have different types 39 39 40 40 // fixtures … … 43 43 // test 44 44 $t->expect('LimeNotEqualException'); 45 $actual->assert Equals($expected, true);45 $actual->assertSame($expected); 46 46 47 47 … … 56 56 57 57 58 // @Test: assertNot Equals() throws no exception if values are equal but types are different and strict is set58 // @Test: assertNotSame() throws no exception if values are equal but types are different 59 59 60 60 // fixtures … … 62 62 $expected = new LimeTesterScalar(1); 63 63 // test 64 $actual->assertNot Equals($expected, true);64 $actual->assertNotSame($expected);