-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathMochaRuntimeObjectStorateTests.m
More file actions
57 lines (45 loc) · 1.17 KB
/
MochaRuntimeObjectStorateTests.m
File metadata and controls
57 lines (45 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//
// MochaRuntimeObjectStorateTests.m
// Cocoa Script
//
// Created by Adam Fedor on 5/23/16.
//
//
#import <XCTest/XCTest.h>
#import "COScript.h"
static NSInteger deallocCalled = 0;
@interface GCObject : NSObject
@end
@implementation GCObject
- (void)dealloc
{
deallocCalled += 1;
}
@end
@interface MochaRuntimeObjectStorateTests : XCTestCase
@end
@implementation MochaRuntimeObjectStorateTests
{
COScript *jsContext;
}
- (void)setUp {
[super setUp];
jsContext = [[COScript alloc] init];
deallocCalled = 0;
}
- (void)tearDown {
[super tearDown];
}
- (void)testStoreAndRemoveObject_ShouldDeallocateIt {
@autoreleasepool {
NSObject *object = [[GCObject alloc] init];
[jsContext pushObject: object withName: @"testObject"];
[jsContext executeString: @"function add() { var newObject = testObject; return newObject}"];
[jsContext callFunctionNamed: @"add" withArguments: nil];
[jsContext deleteObjectWithName: @"testObject"];
object = nil;
}
[[NSRunLoop currentRunLoop] runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.5]];
XCTAssert(deallocCalled == 1, @"Object not deallocated");
}
@end