Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test files for the experimental stuff.
- Loading branch information
Showing
6 changed files
with
401 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?xml version='1.0'?> | ||
<!DOCTYPE signatures SYSTEM "file://localhost/System/Library/DTDs/BridgeSupport.dtd"> | ||
<signatures version='0.9'> | ||
|
||
<!-- | ||
<struct name='JSTTestStruct' type='{JSTTestStruct="b"c"f"f"d"d"i8"c"ui8"C"i16"s"ui16"S"i32"i"ui32"I"i64"q"ui64"Q"next"^{JSTTestStruct}}'/> | ||
--> | ||
|
||
<struct name='JSTTestStruct' type='{JSTTestStruct="b"}'/> | ||
|
||
<function name='objc_msgSend' variadic='true'> | ||
<arg type='@'/> | ||
<arg type=':'/> | ||
<retval type='@'/> | ||
</function> | ||
|
||
<function name='JSTNSString'> | ||
<arg type='@'/> | ||
<retval type='@'/> | ||
</function> | ||
|
||
<class name='JSTTests'> | ||
|
||
<method selector='testBoolValue'> | ||
<retval declared_type='BOOL' type='B'/> | ||
</method> | ||
|
||
<method selector='testClassBoolValue' class_method='true'> | ||
<retval declared_type='BOOL' type='B'/> | ||
</method> | ||
|
||
<method selector='testStringValue'> | ||
<retval declared_type='NSString*' type='@'/> | ||
</method> | ||
|
||
<method selector='testClassStringValue' class_method='true'> | ||
<retval declared_type='NSString*' type='@'/> | ||
</method> | ||
|
||
<method selector='testAppendString'> | ||
<arg name='aString' declared_type='NSString*' type='@' index='0'/> | ||
<retval declared_type='NSString*' type='@'/> | ||
</method> | ||
|
||
<method selector='testClassAppendString' class_method='true'> | ||
<arg name='aString' declared_type='NSString*' type='@' index='0'/> | ||
<retval declared_type='NSString*' type='@'/> | ||
</method> | ||
|
||
<method selector='classTestNSRect' class_method='true'> | ||
<retval declared_type='NSRect' type64='{CGRect={CGPoint=dd}{CGSize=dd}}' type='{_NSRect={_NSPoint=ff}{_NSSize=ff}}'/> | ||
</method> | ||
|
||
<method selector='classTestStruct' class_method='true'> | ||
<!-- <retval declared_type='JSTTestStruct' type64='{JSTTestStruct=cfdcCsSiIqQ^{JSTTestStruct}}' type='{JSTTestStruct=cfdcCsSiIqQ^{JSTTestStruct}}'/> --> | ||
<retval declared_type='JSTTestStruct' type64='{JSTTestStruct=c}' type='{JSTTestStruct=c}'/> --> | ||
</method> | ||
|
||
</class> | ||
|
||
|
||
|
||
|
||
</signatures> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
function jsassert(val, msg) { | ||
if (!val) { | ||
print("Assertion failure!"); | ||
print(msg); | ||
//NSBeep(); | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
[jstalk include:"jstsetup.jstalk"]; | ||
|
||
|
||
var zp = NSZeroPoint; | ||
jsassert(zp, "Can't make a zero point"); | ||
jsassert(zp.x == 0, "Can't grab NSZeroPoint"); | ||
|
||
var name = NSUserName(); | ||
jsassert(name); | ||
|
||
|
||
var d = [NSArray arrayWithObject:NSUserName()]; | ||
jsassert([d count] == 1); | ||
|
||
|
||
var r = NSMakeRect(1, 2, 3, 4); | ||
jsassert(r, "Can't make a rect"); | ||
jsassert(r.origin.x == 1, "Wrong value for x"); | ||
jsassert(r.origin.y == 2, "Wrong value for y"); | ||
jsassert(r.size.width == 3, "Wrong value for width"); | ||
jsassert(r.size.height == 4, "Wrong value for height"); | ||
|
||
|
||
var randomConst = NSBundleDidLoadNotification; | ||
jsassert(randomConst, "Can't find NSBundleDidLoadNotification"); | ||
|
||
jsassert(NSMinYEdge == 1, "Can't find NSMinYEdge"); | ||
jsassert(CGRectMinYEdge == 1, "Can't find NSMinYEdge"); | ||
|
||
var p = NSMakePoint(0,0); | ||
|
||
jsassert(p, "Can't make a point"); | ||
jsassert(p.x == 0, "Can't verify a point"); | ||
|
||
p.x = 1; | ||
jsassert(p.x == 1, "Set a point"); | ||
|
||
|
||
|
||
/* | ||
|
||
if (![private runtimeInfo]) { | ||
[private setRuntimeInfo:[[JSTBridgeSupportLoader sharedController] runtimeInfoForSymbol:NSStringFromClass([self class])]]; | ||
} | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
var s = [JSTTests classTestStruct]; | ||
jsassert(s.b, "s.b is wrong"); | ||
|
||
[jstalk include:"jstsetup.jstalk"]; | ||
|
||
var r = [JSTTests classTestNSRect]; | ||
jsassert(r.origin.x == 1, "r.origin.x"); | ||
jsassert(r.origin.y == 2, "r.origin.y"); | ||
jsassert(r.size.width == 3, "r.size.width"); | ||
jsassert(r.size.height == 4, "r.size.height"); | ||
|
||
NSLog("Woo!"); | ||
|
||
var r = NSMakeRange(1, 1); | ||
r.location = 12; | ||
r.length = 11; | ||
jsassert(r.location == 12, "r.location is wrong"); | ||
jsassert(r.length == 11, "r.length is wrong"); | ||
|
||
|
||
var r = NSMakeRect(1, 2, 3, 4); | ||
|
||
jsassert(r.origin.x == 1, "r.origin.x"); | ||
jsassert(r.origin.y == 2, "r.origin.y"); | ||
jsassert(r.size.width == 3, "r.size.width"); | ||
jsassert(r.size.height == 4, "r.size.height"); | ||
|
||
r.size.width = 10; | ||
r.size.height = 20; | ||
|
||
jsassert(r.size.width == 10, "r.size.width"); | ||
jsassert(r.size.height == 20, "r.size.height"); | ||
|
||
var s = NSMakeSize(1, 2); | ||
jsassert(s.width == 1, "s.width is wrong"); | ||
jsassert(s.height == 2, "s.height is wrong"); | ||
s.width = 3; | ||
s.height = 4; | ||
jsassert(s.width == 3, "s.width is wrong"); | ||
jsassert(s.height == 4, "s.height is wrong"); | ||
|
||
|
||
|
||
|
||
|
||
var r2 = NSMakeRect(5, 6, 7, 8); | ||
jsassert(r2.origin.x == 5, "r2.origin.x"); | ||
jsassert(r2.origin.y == 6, "r2.origin.y"); | ||
jsassert(r2.size.width == 7, "r2.size.width"); | ||
jsassert(r2.size.height == 8, "r2.size.height"); | ||
|
||
|
||
var ti = [[JSTTests alloc] init]; | ||
|
||
//print("Trying the long double"); | ||
//jsassert(55.5 == [ti nonBridgedInstanceMethodReturnAddAndReturnLongDouble:50], | ||
// "nonBridgedInstanceMethodReturnAddAndReturnLongDouble: failed"); | ||
jsassert(34.5 == [ti nonBridgedInstanceMethodReturnAddAndReturnDouble:20], | ||
"nonBridgedInstanceMethodReturnAddAndReturnDouble: failed"); | ||
jsassert(4.5 == [ti nonBridgedInstanceMethodReturnFloat], "nonBridgedInstanceMethodReturnFloat failed"); | ||
jsassert(14.5 == [ti nonBridgedInstanceMethodReturnDouble], "nonBridgedInstanceMethodReturnDouble failed"); | ||
jsassert(24.5 == [ti nonBridgedInstanceMethodReturnAddAndReturnFloat:20], | ||
"nonBridgedInstanceMethodReturnAddAndReturnFloat: failed"); | ||
|
||
|
||
jsassert([ti testBoolValue], "[ti testBoolValue] failed"); | ||
jsassert([JSTTests testClassBoolValue], "[JSTTests testClassBoolValue] failed"); | ||
|
||
jsassert([ti testStringValue] == "String from testStringValue", "[ti testStringValue] failed"); | ||
|
||
jsassert([JSTTests nonBridgedClassMethodReturnString] == "String from nonBridgedClassMethodReturnString", | ||
"[JSTTests nonBridgedClassMethodReturnString] failed"); | ||
|
||
jsassert([ti nonBridgedInstanceMethodReturnString] == "String from nonBridgedInstanceMethodReturnString", | ||
"[ti nonBridgedInstanceMethodReturnString] failed"); | ||
|
||
|
||
var name = NSFullUserName(); | ||
jsassert(name, "NSFullUserName failed"); | ||
jsassert((name + "").toLowerCase() == [name lowercaseString], "Lowercase stuff failed"); | ||
|
||
|
||
|
||
jsassert(([JSTTests nonBridgedClassMethodReturnInt] == 34), "nonBridgedClassMethodReturnInt failed"); | ||
jsassert(([ti nonBridgedInstanceMethodReturnInt] == 36), "nonBridgedInstanceMethodReturnInt failed"); | ||
jsassert(([JSTTests nonBridgedClassMethodAddIntTo34:2] == 36), "nonBridgedClassMethodAddIntTo34 failed"); | ||
jsassert(([ti nonBridgedInstanceMethodAddIntTo34:4] == 38), "nonBridgedInstanceMethodAddIntTo34 failed"); | ||
|
||
|
||
var nilValue = nil; | ||
jsassert(!nilValue, "nilValue is not nil"); | ||
|
||
var randomConst = NSBundleDidLoadNotification; | ||
jsassert(randomConst == "NSBundleDidLoadNotification", "Can't find the NSBundleDidLoadNotification const"); | ||
|
||
var boolVal = NSZombieEnabled; | ||
jsassert(!boolVal, "Why would NSZombieEnabled be enabled?"); | ||
|
||
jsassert(NSMinYEdge == 1, "Can't find NSMinYEdge"); | ||
jsassert(CGRectMinYEdge == 1, "Can't find CGRectMinYEdge"); | ||
|
||
|
||
var twelve = [NSNumber numberWithInt:12]; | ||
var fifteen = twelve + 3; | ||
jsassert(fifteen == 15, "Can't add NSNumbers to js number!"); | ||
|
||
var scriptURL = [[jstalk env] objectForKey:"scriptURL"]; | ||
scriptURL = [scriptURL lastPathComponent]; | ||
jsassert(scriptURL == "B.jstalk", "lastPathComponent failed"); | ||
|
||
var a = [[jstalk env] objectForKey:"scriptURL"] + "" | ||
var b = [[jstalk env] objectForKey:"scriptURL"]; | ||
|
||
jsassert(a == b, "scriptURL conversions failed"); | ||
|
||
a = [ti testStringValue] + "" | ||
b = ti.testStringValue() + ""; | ||
|
||
jsassert(a == b, "JS style method A call failed"); | ||
|
||
var twelve = NSNumber.numberWithInt(12); | ||
var fifteen = twelve + 3; | ||
jsassert(fifteen == 15, "JS style method B call failed!"); | ||
|
||
var twelve = NSNumber.numberWithInt_(12); | ||
var fifteen = twelve + 3; | ||
//jsassert(fifteen == 15, "JS style method C call failed!"); | ||
|
||
NSLog("Hey! %@ %p", "What's shaking?", ti); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
[jstalk include:"jstsetup.jstalk"]; | ||
|
||
|
||
var d = [NSMutableDictionary dictionary]; | ||
|
||
[d setObject:'seeeee' forKey:'c']; | ||
d['a'] = 'eh'; | ||
d['b'] = 'beee'; | ||
for (var key in d) { | ||
|
||
var value = d[key]; | ||
|
||
if (key === 'a') { | ||
jsassert(value == 'eh', "Got " + value + " for a"); | ||
} | ||
if (key === 'b') { | ||
jsassert(value == 'beee', "Got " + value + " for b"); | ||
} | ||
if (key === 'c') { | ||
jsassert(value == 'seeeee', "Got " + value + " for c"); | ||
} | ||
} | ||
|
||
|
||
var args = [NSMutableArray array]; | ||
|
||
[args addObject:"one"]; | ||
[args addObject:"two"]; | ||
[args addObject:"three"]; | ||
|
||
|
||
for (idx in args) { | ||
|
||
var checker = function(value, s) { | ||
if (idx == 0) { | ||
jsassert(value == 'one', "Got " + value + " for 1 " + s); | ||
} | ||
if (idx == 1) { | ||
jsassert(value == 'two', "Got " + value + " for 2 " + s); | ||
} | ||
if (idx == 2) { | ||
jsassert(value == 'three', "Got " + value + " for 3 " + s); | ||
} | ||
} | ||
|
||
checker([args objectAtIndex:idx], "objectAtIndex"); | ||
checker(args[idx], "direct whatever"); | ||
|
||
} | ||
|
||
var gotException = false; | ||
|
||
try { | ||
var x = args[5]; | ||
} | ||
catch(err) { | ||
gotException = true; | ||
} | ||
|
||
jsassert(gotException, "Didn't get the exception when trying to grab an array index that was out of bounds"); |
Oops, something went wrong.