Permalink
Browse files

improve a bit is_equal and fix it for Integer-Integer

  • Loading branch information...
1 parent b514bb9 commit 68c48f9825bf726f3425c8a788ff3871576eb361 @NotFound committed Oct 26, 2011
Showing with 27 additions and 3 deletions.
  1. +2 −2 t/base/features.t
  2. +20 −0 winxedxx_classes.cxx
  3. +1 −0 winxedxx_default.h
  4. +1 −0 winxedxx_integer.h
  5. +1 −0 winxedxx_null.h
  6. +1 −0 winxedxx_object.h
  7. +1 −1 winxedxx_objectptr.cxx
View
@@ -306,9 +306,9 @@ function main [main] (args)
var vi2 = 42;
var vi3 = 7;
- test.todo(vi1 == vi2, "operator == : x == same class, same value");
+ test.ok(vi1 == vi2, "operator == : x == same class, same value");
test.nok(vi1 == vi3, "operator == : x == same class, not same value");
- test.ntodo(vi1 != vi2, "operator != : x != same class, same value");
+ test.nok(vi1 != vi2, "operator != : x != same class, same value");
test.ok(test === test, "operator === : x === x");
test.nok(test !== test, "operator !== : x !== x");
View
@@ -62,6 +62,12 @@ std::string WxxNull::get_string()
return std::string();
}
+int WxxNull::is_equal(const WxxObject &to)
+{
+ nullaccess("is_equal");
+ return 0;
+}
+
WxxObject & WxxNull::set(int value)
{
nullaccess("set");
@@ -243,6 +249,12 @@ std::string WxxDefault::get_string()
return std::string();
}
+int WxxDefault::is_equal(const WxxObject &to)
+{
+ notimplemented("is_equal");
+ return 0;
+}
+
WxxObject & WxxDefault::set(int value)
{
notimplemented("set");
@@ -388,6 +400,14 @@ std::string WxxInteger::get_string()
return oss.str();
}
+int WxxInteger::is_equal(const WxxObject &to)
+{
+ if (const WxxInteger *fromint = dynamic_cast<const WxxInteger *>(& to))
+ return i == fromint->i;
+ else
+ return false;
+}
+
WxxObject & WxxInteger::set(int value)
{
i = value;
View
@@ -24,6 +24,7 @@ class WxxDefault : public WxxObject
double get_number();
int elements();
virtual std::string get_string();
+ int is_equal(const WxxObject &to);
WxxObject & set(int value);
WxxObject & set(double value);
WxxObject & set(const char *s);
View
@@ -28,6 +28,7 @@ class WxxInteger : public WxxDefault
int get_integer();
double get_number();
std::string get_string();
+ int is_equal(const WxxObject &to);
WxxObject & set(int value);
WxxObject & set(double value);
void increment();
View
@@ -19,6 +19,7 @@ class WxxNull : public WxxObject
double get_number();
int elements();
std::string get_string();
+ int is_equal(const WxxObject &to);
WxxObject & set(int value);
WxxObject & set(double value);
WxxObject & set(const char *s);
View
@@ -18,6 +18,7 @@ class WxxObject
virtual double get_number() = 0;
virtual int elements() = 0;
virtual std::string get_string() = 0;
+ virtual int is_equal(const WxxObject &to) = 0;
virtual WxxObject & set(int value) = 0;
virtual WxxObject & set(double value) = 0;
virtual WxxObject & set(const char *s) = 0;
View
@@ -136,7 +136,7 @@ int WxxObjectPtr::is_equal (const WxxObjectPtr &from) const
{
if (object == from.object)
return true;
- return false;
+ return object->is_equal(*from.object);
}
int WxxObjectPtr::is_same(const WxxObjectPtr &from) const

0 comments on commit 68c48f9

Please sign in to comment.