Browse Source

Updated externs test.

Mark Sibly 9 years ago
parent
commit
f8e15ece84
3 changed files with 11 additions and 0 deletions
  1. 5 0
      tests/monkey/externs.cpp
  2. 2 0
      tests/monkey/externs.h
  3. 4 0
      tests/monkey/externs.monkey2

+ 5 - 0
tests/monkey/externs.cpp

@@ -47,6 +47,11 @@ T::~T(){
 	puts( "T::~T()" );
 	puts( "T::~T()" );
 }
 }
 
 
+bool T::operator==( T *that ){
+	puts( "T::operator==(T*)" );
+	return this==that;
+}
+
 void glue_E( C *c ){
 void glue_E( C *c ){
 	puts( "::glue_E( C* )" );
 	puts( "::glue_E( C* )" );
 }
 }

+ 2 - 0
tests/monkey/externs.h

@@ -51,6 +51,8 @@ public:
 	T( int x );
 	T( int x );
 	
 	
 	~T();
 	~T();
+	
+	bool operator==( T *that );
 };
 };
 
 
 void glue_E( C *c );
 void glue_E( C *c );

+ 4 - 0
tests/monkey/externs.monkey2

@@ -47,6 +47,8 @@ Class T Extends Void
 	
 	
 	Method New( x:Int )
 	Method New( x:Int )
 	
 	
+	Operator=:Bool( t:T )="operator=="
+	
 	Function Destroy( t:T )="delete"
 	Function Destroy( t:T )="delete"
 	
 	
 End
 End
@@ -73,6 +75,8 @@ Function Main()
 	
 	
 	Local t:=New T		'T::T()
 	Local t:=New T		'T::T()
 	
 	
+	If t=t Print "Yes"	'T::operator==(T*), "Yes"
+	
 	T.Destroy( t )		'T::~T()
 	T.Destroy( t )		'T::~T()
 	
 	
 	New C().E()			'C::C(), ::glue_E()
 	New C().E()			'C::C(), ::glue_E()