diff dstep/foundation/NSScriptWhoseTests.d @ 14:89f3c3ef1fd2

Added the Foundation framework
author Jacob Carlborg <doob@me.com>
date Mon, 03 Aug 2009 15:23:15 +0200
parents
children 19885b43130e
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dstep/foundation/NSScriptWhoseTests.d	Mon Aug 03 15:23:15 2009 +0200
@@ -0,0 +1,159 @@
+/**
+ * Copyright: Copyright (c) 2009 Jacob Carlborg.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: Aug 3, 2009 
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
+ */
+module dstep.foundation.NSScriptWhoseTests;
+
+import dstep.foundation.NSArray;
+import dstep.foundation.NSObject;
+import dstep.foundation.NSScriptObjectSpecifier;
+import dstep.foundation.NSString;
+import dstep.objc.bridge.Bridge;
+import dstep.objc.objc : id;
+
+alias NSUInteger NSTestComparisonOperation;
+
+enum
+{
+	NSEqualToComparison = 0,
+	NSLessThanOrEqualToComparison,
+	NSLessThanComparison,
+	NSGreaterThanOrEqualToComparison,
+	NSGreaterThanComparison,
+	NSBeginsWithComparison,
+	NSEndsWithComparison,
+	NSContainsComparison
+}
+
+class NSLogicalTest : NSScriptWhoseTest
+{
+	mixin ObjcWrap;
+
+	Object initAndTestWithTests (NSArray subTests)
+	{
+		return invokeObjcSelf!(Object, "initAndTestWithTests:", NSArray)(subTests);
+	}
+
+	this (NSArray subTests)
+	{
+		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
+		id result = Bridge.invokeObjcMethod!(id, "initAndTestWithTests:", NSArray)(objcObject, subTests);
+
+		if (result)
+			objcObject = ret;
+
+		dObject = this;
+	}
+
+	Object initOrTestWithTests (NSArray subTests)
+	{
+		return invokeObjcSelf!(Object, "initOrTestWithTests:", NSArray)(subTests);
+	}
+
+	this (NSArray subTests)
+	{
+		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
+		id result = Bridge.invokeObjcMethod!(id, "initOrTestWithTests:", NSArray)(objcObject, subTests);
+
+		if (result)
+			objcObject = ret;
+
+		dObject = this;
+	}
+
+	Object initNotTestWithTest (NSScriptWhoseTest subTest)
+	{
+		return invokeObjcSelf!(Object, "initNotTestWithTest:", NSScriptWhoseTest)(subTest);
+	}
+
+	this (NSScriptWhoseTest subTest)
+	{
+		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
+		id result = Bridge.invokeObjcMethod!(id, "initNotTestWithTest:", NSScriptWhoseTest)(objcObject, subTest);
+
+		if (result)
+			objcObject = ret;
+
+		dObject = this;
+	}
+}
+
+class NSSpecifierTest : NSScriptWhoseTest
+{
+	mixin ObjcWrap;
+
+	Object initWithObjectSpecifier (NSScriptObjectSpecifier obj1, uint compOp, Object obj2)
+	{
+		return invokeObjcSelf!(Object, "initWithObjectSpecifier:comparisonOperator:testObject:", NSScriptObjectSpecifier, uint, Object)(obj1, compOp, obj2);
+	}
+
+	this (NSScriptObjectSpecifier obj1, uint compOp, Object obj2)
+	{
+		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
+		id result = Bridge.invokeObjcMethod!(id, "initWithObjectSpecifier:comparisonOperator:testObject:", NSScriptObjectSpecifier, uint, Object)(objcObject, obj1, compOp, obj2);
+
+		if (result)
+			objcObject = ret;
+
+		dObject = this;
+	}
+}
+
+class NSScriptWhoseTest : NSObject, INSCoding
+{
+	mixin ObjcWrap;
+
+	bool isTrue ()
+	{
+		return invokeObjcSelf!(bool, "isTrue");
+	}
+
+	void encodeWithCoder (NSCoder aCoder)
+	{
+		return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder);
+	}
+
+	Object initWithCoder (NSCoder aDecoder)
+	{
+		return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder);
+	}
+
+	this (NSCoder aDecoder)
+	{
+		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
+		id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder);
+
+		if (result)
+			objcObject = ret;
+
+		dObject = this;
+	}
+}
+
+template TNSComparisonMethods ()
+{
+	bool isEqualTo (Object object);
+	bool isLessThanOrEqualTo (Object object);
+	bool isLessThan (Object object);
+	bool isGreaterThanOrEqualTo (Object object);
+	bool isGreaterThan (Object object);
+	bool isNotEqualTo (Object object);
+	bool doesContain (Object object);
+	bool isLike (NSString object);
+	bool isCaseInsensitiveLike (NSString object);
+}
+
+template TNSScriptingComparisonMethods ()
+{
+	bool scriptingIsEqualTo (Object object);
+	bool scriptingIsLessThanOrEqualTo (Object object);
+	bool scriptingIsLessThan (Object object);
+	bool scriptingIsGreaterThanOrEqualTo (Object object);
+	bool scriptingIsGreaterThan (Object object);
+	bool scriptingBeginsWith (Object object);
+	bool scriptingEndsWith (Object object);
+	bool scriptingContains (Object object);
+}
+