Nimble
Use Nimble to express the expected outcomes of Swift or Objective-C expressions. Inspired by Cedar.
// Swift
expect(1 + 1).to(equal(2))
expect(1.2).to(beCloseTo(1.1, within: 0.1))
expect(3) > 2
expect("seahorse").to(contain("sea"))
expect(["Atlantic", "Pacific"]).toNot(contain("Mississippi"))
expect(ocean.isClean).toEventually(beTruthy())
How to Use Nimble
Table of Contents generated with DocToc
- Some Background: Expressing Outcomes Using Assertions in XCTest
- Nimble: Expectations Using
expect(...).to
- Built-in Matcher Functions
- Writing Your Own Matchers
- Installing Nimble
Some Background: Expressing Outcomes Using Assertions in XCTest
Apple’s Xcode includes the XCTest framework, which provides
assertion macros to test whether code behaves properly.
For example, to assert that 1 + 1 = 2
, XCTest has you write:
// Swift
XCTAssertEqual(1 + 1, 2, "expected one plus one to equal two")
Or, in Objective-C:
// Objective-C
XCTAssertEqual(1 + 1, 2, @"expected one plus one to equal two");
XCTest assertions have a couple of drawbacks:
- Not enough macros. There’s no easy way to assert that a string contains a particular substring, or that a number is less than or equal to another.
- It’s hard to write asynchronous tests. XCTest forces you to write a lot of boilerplate code.
Nimble addresses these concerns.
Nimble: Expectations Using expect(...).to
Nimble allows you to express expectations using a natural, easily understood language:
// Swift
import Nimble
expect(seagull.squawk).to(equal("Squee!"))
// Objective-C
@import Nimble;
expect(seagull.squawk).to(equal(@"Squee!"));
The
expect
function autocompletes to includefile:
andline:
, but these parameters are optional. Use the default values to have Xcode highlight the correct line when an expectation is not met.
To perform the opposite expectation–to assert something is not
equal–use toNot
or notTo
:
// Swift
import Nimble
expect(seagull.squawk).toNot(equal("Oh, hello there!"))
expect(seagull.squawk).notTo(equal("Oh, hello there!"))
// Objective-C
@import Nimble;
expect(seagull.squawk).toNot(equal(@"Oh, hello there!"));
expect(seagull.squawk).notTo(equal(@"Oh, hello there!"));
Custom Failure Messages
Would you like to add more information to the test’s failure messages? Use the description
optional argument to add your own text:
// Swift
expect(1 + 1).to(equal(3))
// failed - expected to equal <3>, got <2>
expect(1 + 1).to(equal(3), description: "Make sure libKindergartenMath is loaded")
// failed - Make sure libKindergartenMath is loaded
// expected to equal <3>, got <2>
Or the *WithDescription version in Objective-C:
// Objective-C
@import Nimble;
expect(@(1+1)).to(equal(@3));
// failed - expected to equal <3.0000>, got <2.0000>
expect(@(1+1)).toWithDescription(equal(@3), @"Make sure libKindergartenMath is loaded");
// failed - Make sure libKindergartenMath is loaded
// expected to equal <3.0000>, got <2.0000>
Type Safety
Nimble makes sure you don’t compare two types that don’t match:
// Swift
// Does not compile:
expect(1 + 1).to(equal("Squee!"))
Nimble uses generics–only available in Swift–to ensure type correctness. That means type checking is not available when using Nimble in Objective-C. :sob:
Operator Overloads
Tired of so much typing? With Nimble, you can use overloaded operators
like ==
for equivalence, or >
for comparisons:
// Swift
// Passes if squawk does not equal "Hi!":
expect(seagull.squawk) != "Hi!"
// Passes if 10 is greater than 2:
expect(10) > 2
Operator overloads are only available in Swift, so you won’t be able to use this syntax in Objective-C. :broken_heart:
Lazily Computed Values
The expect
function doesn’t evaluate the value it’s given until it’s
time to match. So Nimble can test whether an expression raises an
exception once evaluated:
// Swift
// Note: Swift currently doesn't have exceptions.
// Only Objective-C code can raise exceptions
// that Nimble will catch.
// (see https://github.com/Quick/Nimble/issues/220#issuecomment-172667064)
let exception = NSException(
name: NSInternalInconsistencyException,
reason: "Not enough fish in the sea.",
userInfo: ["something": "is fishy"])
expect { exception.raise() }.to(raiseException())
// Also, you can customize raiseException to be more specific
expect { exception.raise() }.to(raiseException(named: NSInternalInconsistencyException))
expect { exception.raise() }.to(raiseException(
named: NSInternalInconsistencyException,
reason: "Not enough fish in the sea"))
expect { exception.raise() }.to(raiseException(
named: NSInternalInconsistencyException,
reason: "Not enough fish in the sea",
userInfo: ["something": "is fishy"]))
Objective-C works the same way, but you must use the expectAction
macro when making an expectation on an expression that has no return
value:
// Objective-C
NSException *exception = [NSException exceptionWithName:NSInternalInconsistencyException
reason:@"Not enough fish in the sea."
userInfo:nil];
expectAction(^{ [exception raise]; }).to(raiseException());
// Use the property-block syntax to be more specific.
expectAction(^{ [exception raise]; }).to(raiseException().named(NSInternalInconsistencyException));
expectAction(^{ [exception raise]; }).to(raiseException().
named(NSInternalInconsistencyException).
reason("Not enough fish in the sea"));
expectAction(^{ [exception raise]; }).to(raiseException().
named(NSInternalInconsistencyException).
reason("Not enough fish in the sea").
userInfo(@{@"something": @"is fishy"}));
// You can also pass a block for custom matching of the raised exception
expectAction(exception.raise()).to(raiseException().satisfyingBlock(^(NSException *exception) {
expect(exception.name).to(beginWith(NSInternalInconsistencyException));
}));
C Primitives
Some testing frameworks make it hard to test primitive C values. In Nimble, it just works:
// Swift
let actual: CInt = 1
let expectedValue: CInt = 1
expect(actual).to(equal(expectedValue))
In fact, Nimble uses type inference, so you can write the above without explicitly specifying both types:
// Swift
expect(1 as CInt).to(equal(1))
In Objective-C, Nimble only supports Objective-C objects. To make expectations on primitive C values, wrap then in an object literal:
expect(@(1 + 1)).to(equal(@2));
Async/Await Support
Nimble makes it easy to await for an async function to complete. Simply pass
the async function in to expect
:
// Swift
await expect { await aFunctionReturning1() }.to(equal(1))
The async function is awaited on first, before passing it to the matcher. This enables the matcher to run synchronous code like before, without caring about whether the value it’s processing was abtained async or not.
Async support is Swift-only, and it requires that you execute the test in an
async context. For XCTest, this is as simple as marking your test function with
async
. If you use Quick, all tests in Quick 6 are executed in an async context.
In Quick 7 and later, only tests that are in an AsyncSpec
subclass will be
executed in an async context.
To avoid a compiler errors when using synchronous expect
in asynchronous contexts,
expect
with async expressions does not support autoclosures. However, the expecta
(expect async) function is provided as an alternative, which does support autoclosures.
// Swift
await expecta(await aFunctionReturning1()).to(equal(1)))
Similarly, if you’re ever in a situation where you want to force the compiler to
produce a SyncExpectation
, you can use the expects
(expect sync) function to
produce a SyncExpectation
. Like so:
// Swift
expects(someNonAsyncFunction()).to(equal(1)))
expects(await someAsyncFunction()).to(equal(1)) // Compiler error: 'async' call in an autoclosure that does not support concurrency
Async Matchers
In addition to asserting on async functions prior to passing them to a
synchronous predicate, you can also write matchers that directly take in an
async value. These are called AsyncPredicate
s. This is most obviously useful
when directly asserting against an actor. In addition to writing your own
async matchers, Nimble currently ships with async versions of the following
predicates:
allPass
containElementSatisfying
satisfyAllOf
and the&&
operator overload accept bothAsyncPredicate
and synchronousPredicate
s.satisfyAnyOf
and the||
operator overload accept bothAsyncPredicate
and synchronousPredicate
s.
Note: Async/Await support is different than the toEventually
/toEventuallyNot
feature described below.
Polling Expectations
In Nimble, it’s easy to make expectations on values that are updated
asynchronously. Just use toEventually
or toEventuallyNot
:
// Swift
DispatchQueue.main.async {
ocean.add("dolphins")
ocean.add("whales")
}
expect(ocean).toEventually(contain("dolphins", "whales"))
// Objective-C
dispatch_async(dispatch_get_main_queue(), ^{
[ocean add:@"dolphins"];
[ocean add:@"whales"];
});
expect(ocean).toEventually(contain(@"dolphins", @"whales"));
Note: toEventually triggers its polls on the main thread. Blocking the main thread will cause Nimble to stop the run loop. This can cause test pollution for whatever incomplete code that was running on the main thread. Blocking the main thread can be caused by blocking IO, calls to sleep(), deadlocks, and synchronous IPC.
In the above example, ocean
is constantly re-evaluated. If it ever
contains dolphins and whales, the expectation passes. If ocean
still
doesn’t contain them, even after being continuously re-evaluated for one
whole second, the expectation fails.
Using Polling Expectations in Async Tests
You can easily use toEventually
or toEventuallyNot
in async contexts as
well. You only need to add an await
statement to the beginning of the line:
// Swift
DispatchQueue.main.async {
ocean.add("dolphins")
ocean.add("whales")
}
await expect(ocean).toEventually(contain("dolphens", "whiles"))
Starting in Nimble 12, toEventually
et. al. now also supports async
expectations. For example, the following test is now supported:
actor MyActor {
private var counter = 0
func access() -> Int {
counter += 1
return counter
}
}
let subject = MyActor()
await expect { await subject.access() }.toEventually(equal(2))
Verifying a Predicate will Never or Always Match
You can also test that a value always or never matches throughout the length of the timeout. Use toNever
and toAlways
for this:
// Swift
ocean.add("dolphins")
expect(ocean).toAlways(contain("dolphins"))
expect(ocean).toNever(contain("hares"))
// Objective-C
[ocean add:@"dolphins"]
expect(ocean).toAlways(contain(@"dolphins"))
expect(ocean).toNever(contain(@"hares"))
Waiting for a Callback to be Called
You can also provide a callback by using the waitUntil
function:
// Swift
waitUntil { done in
ocean.goFish { success in
expect(success).to(beTrue())
done()
}
}
// Objective-C
waitUntil(^(void (^done)(void)){
[ocean goFishWithHandler:^(BOOL success){
expect(success).to(beTrue());
done();
}];
});
waitUntil
also optionally takes a timeout parameter:
// Swift
waitUntil(timeout: .seconds(10)) { done in
ocean.goFish { success in
expect(success).to(beTrue())
done()
}
}
// Objective-C
waitUntilTimeout(10, ^(void (^done)(void)){
[ocean goFishWithHandler:^(BOOL success){
expect(success).to(beTrue());
done();
}];
});
Note: waitUntil
triggers its timeout code on the main thread. Blocking the main
thread will cause Nimble to stop the run loop to continue. This can cause test
pollution for whatever incomplete code that was running on the main thread.
Blocking the main thread can be caused by blocking IO, calls to sleep(),
deadlocks, and synchronous IPC.
Changing the Timeout and Polling Intervals
Sometimes it takes more than a second for a value to update. In those
cases, use the timeout
parameter:
// Swift
// Waits three seconds for ocean to contain "starfish":
expect(ocean).toEventually(contain("starfish"), timeout: .seconds(3))
// Evaluate someValue every 0.2 seconds repeatedly until it equals 100, or fails if it timeouts after 5.5 seconds.
expect(someValue).toEventually(equal(100), timeout: .milliseconds(5500), pollInterval: .milliseconds(200))
// Objective-C
// Waits three seconds for ocean to contain "starfish":
expect(ocean).withTimeout(3).toEventually(contain(@"starfish"));
Changing default Timeout and Poll Intervals
In some cases (e.g. when running on slower machines) it can be useful to modify the default timeout and poll interval values. This can be done as follows:
// Swift
// Increase the global timeout to 5 seconds:
Nimble.PollingDefaults.timeout = .seconds(5)
// Slow the polling interval to 0.1 seconds:
Nimble.PollingDefaults.pollInterval = .milliseconds(100)
You can set these globally at test startup in two ways:
Quick
If you use Quick, add a QuickConfiguration
subclass which sets your desired PollingDefaults
.
import Quick
import Nimble
class PollingConfiguration: QuickConfiguration {
override class func configure(_ configuration: QCKConfiguration) {
Nimble.PollingDefaults.timeout = .seconds(5)
Nimble.PollingDefaults.pollInterval = .milliseconds(100)
}
}
XCTest
If you use XCTest, add an object that conforms to XCTestObservation
and implement testBundleWillStart(_:)
.
Additionally, you will need to register this observer with the XCTestObservationCenter
at test startup. To do this, set the NSPrincipalClass
key in your test bundle’s Info.plist and implement a class with that same name.
For example
<!-- Info.plist -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- ... -->
<key>NSPrincipalClass</key>
<string>MyTests.TestSetup</string>
</dict>
</plist>
// TestSetup.swift
import XCTest
import Nimble
@objc
class TestSetup: NSObject {
override init() {
XCTestObservationCenter.shared.register(PollingConfigurationTestObserver())
}
}
class PollingConfigurationTestObserver: NSObject, XCTestObserver {
func testBundleWillStart(_ testBundle: Bundle) {
Nimble.PollingDefaults.timeout = .seconds(5)
Nimble.PollingDefaults.pollInterval = .milliseconds(100)
}
}
In Linux, you can implement LinuxMain
to set the PollingDefaults before calling XCTMain
.
Objective-C Support
Nimble has full support for Objective-C. However, there are two things to keep in mind when using Nimble in Objective-C:
- All parameters passed to the
expect
function, as well as matcher functions likeequal
, must be Objective-C objects or can be converted into anNSObject
equivalent:
// Objective-C
@import Nimble;
expect(@(1 + 1)).to(equal(@2));
expect(@"Hello world").to(contain(@"world"));
// Boxed as NSNumber *
expect(2).to(equal(2));
expect(1.2).to(beLessThan(2.0));
expect(true).to(beTruthy());
// Boxed as NSString *
expect("Hello world").to(equal("Hello world"));
// Boxed as NSRange
expect(NSMakeRange(1, 10)).to(equal(NSMakeRange(1, 10)));
- To make an expectation on an expression that does not return a value,
such as
-[NSException raise]
, useexpectAction
instead ofexpect
:
// Objective-C
expectAction(^{ [exception raise]; }).to(raiseException());
The following types are currently converted to an NSObject
type:
- C Numeric types are converted to
NSNumber *
NSRange
is converted toNSValue *
char *
is converted toNSString *
For the following matchers:
equal
beGreaterThan
beGreaterThanOrEqual
beLessThan
beLessThanOrEqual
beCloseTo
beTrue
beFalse
beTruthy
beFalsy
haveCount
If you would like to see more, file an issue.
Disabling Objective-C Shorthand
Nimble provides a shorthand for expressing expectations using the
expect
function. To disable this shorthand in Objective-C, define the
NIMBLE_DISABLE_SHORT_SYNTAX
macro somewhere in your code before
importing Nimble:
#define NIMBLE_DISABLE_SHORT_SYNTAX 1
@import Nimble;
NMB_expect(^{ return seagull.squawk; }, __FILE__, __LINE__).to(NMB_equal(@"Squee!"));
Disabling the shorthand is useful if you’re testing functions with names that conflict with Nimble functions, such as
expect
orequal
. If that’s not the case, there’s no point in disabling the shorthand.
Built-in Matcher Functions
Nimble includes a wide variety of matcher functions.
Type Checking
Nimble supports checking the type membership of any kind of object, whether Objective-C conformant or not:
// Swift
protocol SomeProtocol{}
class SomeClassConformingToProtocol: SomeProtocol{}
struct SomeStructConformingToProtocol: SomeProtocol{}
// The following tests pass
expect(1).to(beAKindOf(Int.self))
expect("turtle").to(beAKindOf(String.self))
let classObject = SomeClassConformingToProtocol()
expect(classObject).to(beAKindOf(SomeProtocol.self))
expect(classObject).to(beAKindOf(SomeClassConformingToProtocol.self))
expect(classObject).toNot(beAKindOf(SomeStructConformingToProtocol.self))
let structObject = SomeStructConformingToProtocol()
expect(structObject).to(beAKindOf(SomeProtocol.self))
expect(structObject).to(beAKindOf(SomeStructConformingToProtocol.self))
expect(structObject).toNot(beAKindOf(SomeClassConformingToProtocol.self))
// Objective-C
// The following tests pass
NSMutableArray *array = [NSMutableArray array];
expect(array).to(beAKindOf([NSArray class]));
expect(@1).toNot(beAKindOf([NSNull class]));
Objects can be tested for their exact types using the beAnInstanceOf
matcher:
// Swift
protocol SomeProtocol{}
class SomeClassConformingToProtocol: SomeProtocol{}
struct SomeStructConformingToProtocol: SomeProtocol{}
// Unlike the 'beKindOf' matcher, the 'beAnInstanceOf' matcher only
// passes if the object is the EXACT type requested. The following
// tests pass -- note its behavior when working in an inheritance hierarchy.
expect(1).to(beAnInstanceOf(Int.self))
expect("turtle").to(beAnInstanceOf(String.self))
let classObject = SomeClassConformingToProtocol()
expect(classObject).toNot(beAnInstanceOf(SomeProtocol.self))
expect(classObject).to(beAnInstanceOf(SomeClassConformingToProtocol.self))
expect(classObject).toNot(beAnInstanceOf(SomeStructConformingToProtocol.self))
let structObject = SomeStructConformingToProtocol()
expect(structObject).toNot(beAnInstanceOf(SomeProtocol.self))
expect(structObject).to(beAnInstanceOf(SomeStructConformingToProtocol.self))
expect(structObject).toNot(beAnInstanceOf(SomeClassConformingToProtocol.self))
Equivalence
// Swift
// Passes if 'actual' is equivalent to 'expected':
expect(actual).to(equal(expected))
expect(actual) == expected
// Passes if 'actual' is not equivalent to 'expected':
expect(actual).toNot(equal(expected))
expect(actual) != expected
// Objective-C
// Passes if 'actual' is equivalent to 'expected':
expect(actual).to(equal(expected))
// Passes if 'actual' is not equivalent to 'expected':
expect(actual).toNot(equal(expected))
Values must be Equatable
, Comparable
, or subclasses of NSObject
.
equal
will always fail when used to compare one or more nil
values.
Identity
// Swift
// Passes if 'actual' has the same pointer address as 'expected':
expect(actual).to(beIdenticalTo(expected))
expect(actual) === expected
// Passes if 'actual' does not have the same pointer address as 'expected':
expect(actual).toNot(beIdenticalTo(expected))
expect(actual) !== expected
It is important to remember that beIdenticalTo
only makes sense when comparing
types with reference semantics, which have a notion of identity. In Swift,
that means types that are defined as a class
.
This matcher will not work when comparing types with value semantics such as
those defined as a struct
or enum
. If you need to compare two value types,
consider what it means for instances of your type to be identical. This may mean
comparing individual properties or, if it makes sense to do so, conforming your type
to Equatable
and using Nimble’s equivalence matchers instead.
// Objective-C
// Passes if 'actual' has the same pointer address as 'expected':
expect(actual).to(beIdenticalTo(expected));
// Passes if 'actual' does not have the same pointer address as 'expected':
expect(actual).toNot(beIdenticalTo(expected));
Comparisons
// Swift
expect(actual).to(beLessThan(expected))
expect(actual) < expected
expect(actual).to(beLessThanOrEqualTo(expected))
expect(actual) <= expected
expect(actual).to(beGreaterThan(expected))
expect(actual) > expected
expect(actual).to(beGreaterThanOrEqualTo(expected))
expect(actual) >= expected
// Objective-C
expect(actual).to(beLessThan(expected));
expect(actual).to(beLessThanOrEqualTo(expected));
expect(actual).to(beGreaterThan(expected));
expect(actual).to(beGreaterThanOrEqualTo(expected));
Values given to the comparison matchers above must implement
Comparable
.
Because of how computers represent floating point numbers, assertions
that two floating point numbers be equal will sometimes fail. To express
that two numbers should be close to one another within a certain margin
of error, use beCloseTo
:
// Swift
expect(actual).to(beCloseTo(expected, within: delta))
// Objective-C
expect(actual).to(beCloseTo(expected).within(delta));
For example, to assert that 10.01
is close to 10
, you can write:
// Swift
expect(10.01).to(beCloseTo(10, within: 0.1))
// Objective-C
expect(@(10.01)).to(beCloseTo(@10).within(0.1));
There is also an operator shortcut available in Swift:
// Swift
expect(actual) ≈ expected
expect(actual) ≈ (expected, delta)
(Type option+x to get ≈
on a U.S. keyboard)
The former version uses the default delta of 0.0001. Here is yet another way to do this:
// Swift
expect(actual) ≈ expected ± delta
expect(actual) == expected ± delta
(Type option+shift+= to get ±
on a U.S. keyboard)
If you are comparing arrays of floating point numbers, you’ll find the following useful:
// Swift
expect([0.0, 2.0]) ≈ [0.0001, 2.0001]
expect([0.0, 2.0]).to(beCloseTo([0.1, 2.1], within: 0.1))
Values given to the
beCloseTo
matcher must conform toFloatingPoint
.
Types/Classes
// Swift
// Passes if 'instance' is an instance of 'aClass':
expect(instance).to(beAnInstanceOf(aClass))
// Passes if 'instance' is an instance of 'aClass' or any of its subclasses:
expect(instance).to(beAKindOf(aClass))
// Objective-C
// Passes if 'instance' is an instance of 'aClass':
expect(instance).to(beAnInstanceOf(aClass));
// Passes if 'instance' is an instance of 'aClass' or any of its subclasses:
expect(instance).to(beAKindOf(aClass));
Instances must be Objective-C objects: subclasses of
NSObject
, or Swift objects bridged to Objective-C with the@objc
prefix.
For example, to assert that dolphin
is a kind of Mammal
:
// Swift
expect(dolphin).to(beAKindOf(Mammal))
// Objective-C
expect(dolphin).to(beAKindOf([Mammal class]));
beAnInstanceOf
uses the-[NSObject isMemberOfClass:]
method to test membership.beAKindOf
uses-[NSObject isKindOfClass:]
.
Truthiness
// Passes if 'actual' is not nil, true, or an object with a boolean value of true:
expect(actual).to(beTruthy())
// Passes if 'actual' is only true (not nil or an object conforming to Boolean true):
expect(actual).to(beTrue())
// Passes if 'actual' is nil, false, or an object with a boolean value of false:
expect(actual).to(beFalsy())
// Passes if 'actual' is only false (not nil or an object conforming to Boolean false):
expect(actual).to(beFalse())
// Passes if 'actual' is nil:
expect(actual).to(beNil())
// Objective-C
// Passes if 'actual' is not nil, true, or an object with a boolean value of true:
expect(actual).to(beTruthy());
// Passes if 'actual' is only true (not nil or an object conforming to Boolean true):
expect(actual).to(beTrue());
// Passes if 'actual' is nil, false, or an object with a boolean value of false:
expect(actual).to(beFalsy());
// Passes if 'actual' is only false (not nil or an object conforming to Boolean false):
expect(actual).to(beFalse());
// Passes if 'actual' is nil:
expect(actual).to(beNil());
Swift Assertions
If you’re using Swift, you can use the throwAssertion
matcher to check if an assertion is thrown (e.g. fatalError()
). This is made possible by @mattgallagher’s CwlPreconditionTesting library.
// Swift
// Passes if 'somethingThatThrows()' throws an assertion,
// such as by calling 'fatalError()' or if a precondition fails:
expect { try somethingThatThrows() }.to(throwAssertion())
expect { () -> Void in fatalError() }.to(throwAssertion())
expect { precondition(false) }.to(throwAssertion())
// Passes if throwing an NSError is not equal to throwing an assertion:
expect { throw NSError(domain: "test", code: 0, userInfo: nil) }.toNot(throwAssertion())
// Passes if the code after the precondition check is not run:
var reachedPoint1 = false
var reachedPoint2 = false
expect {
reachedPoint1 = true
precondition(false, "condition message")
reachedPoint2 = true
}.to(throwAssertion())
expect(reachedPoint1) == true
expect(reachedPoint2) == false
Notes:
- This feature is only available in Swift.
- The tvOS simulator is supported, but using a different mechanism, requiring you to turn off the
Debug executable
scheme setting for your tvOS scheme’s Test configuration.
Swift Error Handling
You can use the throwError
matcher to check if an error is thrown.
// Swift
// Passes if 'somethingThatThrows()' throws an 'Error':
expect { try somethingThatThrows() }.to(throwError())
// Passes if 'somethingThatThrows()' throws an error within a particular domain:
expect { try somethingThatThrows() }.to(throwError { (error: Error) in
expect(error._domain).to(equal(NSCocoaErrorDomain))
})
// Passes if 'somethingThatThrows()' throws a particular error enum case:
expect { try somethingThatThrows() }.to(throwError(NSCocoaError.PropertyListReadCorruptError))
// Passes if 'somethingThatThrows()' throws an error of a particular type:
expect { try somethingThatThrows() }.to(throwError(errorType: NimbleError.self))
When working directly with Error
values, using the matchError
matcher
allows you to perform certain checks on the error itself without having to
explicitly cast the error.
The matchError
matcher allows you to check whether or not the error:
- is the same type of error you are expecting.
- represents a particular error value that you are expecting.
This can be useful when using Result
or Promise
types, for example.
// Swift
let actual: Error = ...
// Passes if 'actual' represents any error value from the NimbleErrorEnum type:
expect(actual).to(matchError(NimbleErrorEnum.self))
// Passes if 'actual' represents the case 'timeout' from the NimbleErrorEnum type:
expect(actual).to(matchError(NimbleErrorEnum.timeout))
// Passes if 'actual' contains an NSError equal to the one provided:
expect(actual).to(matchError(NSError(domain: "err", code: 123, userInfo: nil)))
Note: This feature is only available in Swift.
Exceptions
// Swift
// Passes if 'actual', when evaluated, raises an exception:
expect(actual).to(raiseException())
// Passes if 'actual' raises an exception with the given name:
expect(actual).to(raiseException(named: name))
// Passes if 'actual' raises an exception with the given name and reason:
expect(actual).to(raiseException(named: name, reason: reason))
// Passes if 'actual' raises an exception which passes expectations defined in the given closure:
// (in this case, if the exception's name begins with "a r")
expect { exception.raise() }.to(raiseException { (exception: NSException) in
expect(exception.name).to(beginWith("a r"))
})
// Objective-C
// Passes if 'actual', when evaluated, raises an exception:
expect(actual).to(raiseException())
// Passes if 'actual' raises an exception with the given name
expect(actual).to(raiseException().named(name))
// Passes if 'actual' raises an exception with the given name and reason:
expect(actual).to(raiseException().named(name).reason(reason))
// Passes if 'actual' raises an exception and it passes expectations defined in the given block:
// (in this case, if name begins with "a r")
expect(actual).to(raiseException().satisfyingBlock(^(NSException *exception) {
expect(exception.name).to(beginWith(@"a r"));
}));
Note: Swift currently doesn’t have exceptions (see #220). Only Objective-C code can raise exceptions that Nimble will catch.
Collection Membership
// Swift
// Passes if all of the expected values are members of 'actual':
expect(actual).to(contain(expected...))
// Passes if 'actual' is empty (i.e. it contains no elements):
expect(actual).to(beEmpty())
// Objective-C
// Passes if expected is a member of 'actual':
expect(actual).to(contain(expected));
// Passes if 'actual' is empty (i.e. it contains no elements):
expect(actual).to(beEmpty());
In Swift
contain
takes any number of arguments. The expectation passes if all of them are members of the collection. In Objective-C,contain
only takes one argument for now.
For example, to assert that a list of sea creature names contains “dolphin” and “starfish”:
// Swift
expect(["whale", "dolphin", "starfish"]).to(contain("dolphin", "starfish"))
// Objective-C
expect(@[@"whale", @"dolphin", @"starfish"]).to(contain(@"dolphin"));
expect(@[@"whale", @"dolphin", @"starfish"]).to(contain(@"starfish"));
contain
andbeEmpty
expect collections to be instances ofNSArray
,NSSet
, or a Swift collection composed ofEquatable
elements.
To test whether a set of elements is present at the beginning or end of
an ordered collection, use beginWith
and endWith
:
// Swift
// Passes if the elements in expected appear at the beginning of 'actual':
expect(actual).to(beginWith(expected...))
// Passes if the the elements in expected come at the end of 'actual':
expect(actual).to(endWith(expected...))
// Objective-C
// Passes if the elements in expected appear at the beginning of 'actual':
expect(actual).to(beginWith(expected));
// Passes if the the elements in expected come at the end of 'actual':
expect(actual).to(endWith(expected));
beginWith
andendWith
expect collections to be instances ofNSArray
, or ordered Swift collections composed ofEquatable
elements.
Like contain
, in Objective-C beginWith
and endWith
only support
a single argument for now.
For code that returns collections of complex objects without a strict
ordering, there is the containElementSatisfying
matcher:
// Swift
struct Turtle {
let color: String
}
let turtles: [Turtle] = functionThatReturnsSomeTurtlesInAnyOrder()
// This set of matchers passes regardless of whether the array is
// [{color: "blue"}, {color: "green"}] or [{color: "green"}, {color: "blue"}]:
expect(turtles).to(containElementSatisfying({ turtle in
return turtle.color == "green"
}))
expect(turtles).to(containElementSatisfying({ turtle in
return turtle.color == "blue"
}, "that is a turtle with color 'blue'"))
// The second matcher will incorporate the provided string in the error message
// should it fail
Note: in Swift, containElementSatisfying
also has a variant that takes in an
async function.
// Objective-C
@interface Turtle : NSObject
@property (nonatomic, readonly, nonnull) NSString *color;
@end
@implementation Turtle
@end
NSArray<Turtle *> * __nonnull turtles = functionThatReturnsSomeTurtlesInAnyOrder();
// This set of matchers passes regardless of whether the array is
// [{color: "blue"}, {color: "green"}] or [{color: "green"}, {color: "blue"}]:
expect(turtles).to(containElementSatisfying(^BOOL(id __nonnull object) {
return [[turtle color] isEqualToString:@"green"];
}));
expect(turtles).to(containElementSatisfying(^BOOL(id __nonnull object) {
return [[turtle color] isEqualToString:@"blue"];
}));
For asserting on if the given Comparable
value is inside of a Range
, use the beWithin
matcher.
// Swift
// Passes if 5 is within the range 1 through 10, inclusive
expect(5).to(beWithin(1...10))
// Passes if 5 is not within the range 2 through 4.
expect(5).toNot(beWithin(2..<5))
Strings
// Swift
// Passes if 'actual' contains 'substring':
expect(actual).to(contain(substring))
// Passes if 'actual' begins with 'prefix':
expect(actual).to(beginWith(prefix))
// Passes if 'actual' ends with 'suffix':
expect(actual).to(endWith(suffix))
// Passes if 'actual' represents the empty string, "":
expect(actual).to(beEmpty())
// Passes if 'actual' matches the regular expression defined in 'expected':
expect(actual).to(match(expected))
// Objective-C
// Passes if 'actual' contains 'substring':
expect(actual).to(contain(expected));
// Passes if 'actual' begins with 'prefix':
expect(actual).to(beginWith(prefix));
// Passes if 'actual' ends with 'suffix':
expect(actual).to(endWith(suffix));
// Passes if 'actual' represents the empty string, "":
expect(actual).to(beEmpty());
// Passes if 'actual' matches the regular expression defined in 'expected':
expect(actual).to(match(expected))
Collection Elements
Nimble provides a means to check that all elements of a collection pass a given expectation.
Swift
In Swift, the collection must be an instance of a type conforming to
Sequence
.
// Swift
// Providing a custom function:
expect([1, 2, 3, 4]).to(allPass { $0 < 5 })
// Composing the expectation with another matcher:
expect([1, 2, 3, 4]).to(allPass(beLessThan(5)))
There are also variants of allPass
that check against async matchers, and
that take in async functions:
// Swift
// Providing a custom function:
expect([1, 2, 3, 4]).to(allPass { await asyncFunctionReturningBool($0) })
// Composing the expectation with another matcher:
expect([1, 2, 3, 4]).to(allPass(someAsyncMatcher()))
Objective-C
In Objective-C, the collection must be an instance of a type which implements
the NSFastEnumeration
protocol, and whose elements are instances of a type
which subclasses NSObject
.
Additionally, unlike in Swift, there is no override to specify a custom matcher function.
// Objective-C
expect(@[@1, @2, @3, @4]).to(allPass(beLessThan(@5)));
Collection Count
// Swift
// Passes if 'actual' contains the 'expected' number of elements:
expect(actual).to(haveCount(expected))
// Passes if 'actual' does _not_ contain the 'expected' number of elements:
expect(actual).notTo(haveCount(expected))
// Objective-C
// Passes if 'actual' contains the 'expected' number of elements:
expect(actual).to(haveCount(expected))
// Passes if 'actual' does _not_ contain the 'expected' number of elements:
expect(actual).notTo(haveCount(expected))
For Swift, the actual value must be an instance of a type conforming to Collection
.
For example, instances of Array
, Dictionary
, or Set
.
For Objective-C, the actual value must be one of the following classes, or their subclasses:
NSArray
,NSDictionary
,NSSet
, orNSHashTable
.
Notifications
// Swift
let testNotification = Notification(name: Notification.Name("Foo"), object: nil)
// Passes if the closure in expect { ... } posts a notification to the default
// notification center.
expect {
NotificationCenter.default.post(testNotification)
}.to(postNotifications(equal([testNotification])))
// Passes if the closure in expect { ... } posts a notification to a given
// notification center
let notificationCenter = NotificationCenter()
expect {
notificationCenter.post(testNotification)
}.to(postNotifications(equal([testNotification]), from: notificationCenter))
// Passes if the closure in expect { ... } posts a notification with the provided names to a given
// notification center. Make sure to use this when running tests on Catalina,
// using DistributedNotificationCenter as there is currently no way
// of observing notifications without providing specific names.
let distributedNotificationCenter = DistributedNotificationCenter()
expect {
distributedNotificationCenter.post(testNotification)
}.toEventually(postDistributedNotifications(equal([testNotification]),
from: distributedNotificationCenter,
names: [testNotification.name]))
This matcher is only available in Swift.
Result
// Swift
let aResult: Result<String, Error> = .success("Hooray")
// passes if result is .success
expect(aResult).to(beSuccess())
// passes if result value is .success and validates Success value
expect(aResult).to(beSuccess { value in
expect(value).to(equal("Hooray"))
})
enum AnError: Error {
case somethingHappened
}
let otherResult: Result<String, AnError> = .failure(.somethingHappened)
// passes if result is .failure
expect(otherResult).to(beFailure())
// passes if result value is .failure and validates error
expect(otherResult).to(beFailure { error in
expect(error).to(matchError(AnError.somethingHappened))
})
This matcher is only available in Swift.
Matching a value to any of a group of matchers
// Swift
// passes if actual is either less than 10 or greater than 20
expect(actual).to(satisfyAnyOf(beLessThan(10), beGreaterThan(20)))
// can include any number of matchers -- the following will pass
// **be careful** -- too many matchers can be the sign of an unfocused test
expect(6).to(satisfyAnyOf(equal(2), equal(3), equal(4), equal(5), equal(6), equal(7)))
// in Swift you also have the option to use the || operator to achieve a similar function
expect(82).to(beLessThan(50) || beGreaterThan(80))
Note: In swift, you can mix and match synchronous and asynchronous predicates
using by satisfyAnyOf
/||
.
// Objective-C
// passes if actual is either less than 10 or greater than 20
expect(actual).to(satisfyAnyOf(beLessThan(@10), beGreaterThan(@20)))
// can include any number of matchers -- the following will pass
// **be careful** -- too many matchers can be the sign of an unfocused test
expect(@6).to(satisfyAnyOf(equal(@2), equal(@3), equal(@4), equal(@5), equal(@6), equal(@7)))
Note: This matcher allows you to chain any number of matchers together. This provides flexibility, but if you find yourself chaining many matchers together in one test, consider whether you could instead refactor that single test into multiple, more precisely focused tests for better coverage.
Custom Validation
// Swift
// passes if .succeeded is returned from the closure
expect {
guard case .enumCaseWithAssociatedValueThatIDontCareAbout = actual else {
return .failed(reason: "wrong enum case")
}
return .succeeded
}.to(succeed())
// passes if .failed is returned from the closure
expect {
guard case .enumCaseWithAssociatedValueThatIDontCareAbout = actual else {
return .failed(reason: "wrong enum case")
}
return .succeeded
}.notTo(succeed())
The String
provided with .failed()
is shown when the test fails.
When using toEventually()
be careful not to make state changes or run process intensive code since this closure will be ran many times.
Writing Your Own Matchers
In Nimble, matchers are Swift functions that take an expected
value and return a Predicate
closure. Take equal
, for example:
// Swift
public func equal<T: Equatable>(expectedValue: T?) -> Predicate<T> {
// Can be shortened to:
// Predicate { actual in ... }
//
// But shown with types here for clarity.
return Predicate { (actualExpression: Expression<T>) throws -> PredicateResult in
let msg = ExpectationMessage.expectedActualValueTo("equal <\(expectedValue)>")
if let actualValue = try actualExpression.evaluate() {
return PredicateResult(
bool: actualValue == expectedValue!,
message: msg
)
} else {
return PredicateResult(
status: .fail,
message: msg.appendedBeNilHint()
)
}
}
}
The return value of a Predicate
closure is a PredicateResult
that indicates
whether the actual value matches the expectation and what error message to
display on failure.
The actual
equal
matcher function does not match whenexpected
are nil; the example above has been edited for brevity.
Since matchers are just Swift functions, you can define them anywhere: at the top of your test file, in a file shared by all of your tests, or in an Xcode project you distribute to others.
If you write a matcher you think everyone can use, consider adding it to Nimble’s built-in set of matchers by sending a pull request! Or distribute it yourself via GitHub.
For examples of how to write your own matchers, just check out the
Matchers
directory
to see how Nimble’s built-in set of matchers are implemented. You can
also check out the tips below.
PredicateResult
PredicateResult
is the return struct that Predicate
return to indicate
success and failure. A PredicateResult
is made up of two values:
PredicateStatus
and ExpectationMessage
.
Instead of a boolean, PredicateStatus
captures a trinary set of values:
// Swift
public enum PredicateStatus {
// The predicate "passes" with the given expression
// eg - expect(1).to(equal(1))
case matches
// The predicate "fails" with the given expression
// eg - expect(1).toNot(equal(1))
case doesNotMatch
// The predicate never "passes" with the given expression, even if negated
// eg - expect(nil as Int?).toNot(equal(1))
case fail
// ...
}
Meanwhile, ExpectationMessage
provides messaging semantics for error reporting.
// Swift
public indirect enum ExpectationMessage {
// Emits standard error message:
// eg - "expected to <string>, got <actual>"
case expectedActualValueTo(/* message: */ String)
// Allows any free-form message
// eg - "<string>"
case fail(/* message: */ String)
// ...
}
Predicates should usually depend on either .expectedActualValueTo(..)
or
.fail(..)
when reporting errors. Special cases can be used for the other enum
cases.
Finally, if your Predicate utilizes other Predicates, you can utilize
.appended(details:)
and .appended(message:)
methods to annotate an existing
error with more details.
A common message to append is failing on nils. For that, .appendedBeNilHint()
can be used.
Lazy Evaluation
actualExpression
is a lazy, memoized closure around the value provided to the
expect
function. The expression can either be a closure or a value directly
passed to expect(...)
. In order to determine whether that value matches,
custom matchers should call actualExpression.evaluate()
:
// Swift
public func beNil<T>() -> Predicate<T> {
// Predicate.simpleNilable(..) automatically generates ExpectationMessage for
// us based on the string we provide to it. Also, the 'Nilable' postfix indicates
// that this Predicate supports matching against nil actualExpressions, instead of
// always resulting in a PredicateStatus.fail result -- which is true for
// Predicate.simple(..)
return Predicate.simpleNilable("be nil") { actualExpression in
let actualValue = try actualExpression.evaluate()
return PredicateStatus(bool: actualValue == nil)
}
}
In the above example, actualExpression
is not nil
– it is a closure
that returns a value. The value it returns, which is accessed via the
evaluate()
method, may be nil
. If that value is nil
, the beNil
matcher function returns true
, indicating that the expectation passed.
Type Checking via Swift Generics
Using Swift’s generics, matchers can constrain the type of the actual value
passed to the expect
function by modifying the return type.
For example, the following matcher, haveDescription
, only accepts actual
values that implement the Printable
protocol. It checks their description
against the one provided to the matcher function, and passes if they are the same:
// Swift
public func haveDescription(description: String) -> Predicate<Printable?> {
return Predicate.simple("have description") { actual in
return PredicateStatus(bool: actual.evaluate().description == description)
}
}
Customizing Failure Messages
When using Predicate.simple(..)
or Predicate.simpleNilable(..)
, Nimble
outputs the following failure message when an expectation fails:
// where `message` is the first string argument and
// `actual` is the actual value received in `expect(..)`
"expected to \(message), got <\(actual)>"
You can customize this message by modifying the way you create a Predicate
.
Basic Customization
For slightly more complex error messaging, receive the created failure message
with Predicate.define(..)
:
// Swift
public func equal<T: Equatable>(_ expectedValue: T?) -> Predicate<T> {
return Predicate.define("equal <\(stringify(expectedValue))>") { actualExpression, msg in
let actualValue = try actualExpression.evaluate()
let matches = actualValue == expectedValue && expectedValue != nil
if expectedValue == nil || actualValue == nil {
if expectedValue == nil && actualValue != nil {
return PredicateResult(
status: .fail,
message: msg.appendedBeNilHint()
)
}
return PredicateResult(status: .fail, message: msg)
}
return PredicateResult(bool: matches, message: msg)
}
}
In the example above, msg
is defined based on the string given to
Predicate.define
. The code looks akin to:
// Swift
let msg = ExpectationMessage.expectedActualValueTo("equal <\(stringify(expectedValue))>")
Full Customization
To fully customize the behavior of the Predicate, use the overload that expects
a PredicateResult
to be returned.
Along with PredicateResult
, there are other ExpectationMessage
enum values you can use:
public indirect enum ExpectationMessage {
// Emits standard error message:
// eg - "expected to <message>, got <actual>"
case expectedActualValueTo(/* message: */ String)
// Allows any free-form message
// eg - "<message>"
case fail(/* message: */ String)
// Emits standard error message with a custom actual value instead of the default.
// eg - "expected to <message>, got <actual>"
case expectedCustomValueTo(/* message: */ String, /* actual: */ String)
// Emits standard error message without mentioning the actual value
// eg - "expected to <message>"
case expectedTo(/* message: */ String)
// ...
}
For matchers that compose other matchers, there are a handful of helper functions to annotate messages.
appended(message: String)
is used to append to the original failure message:
// produces "expected to be true, got <actual> (use beFalse() for inverse)"
// appended message do show up inline in Xcode.
.expectedActualValueTo("be true").appended(message: " (use beFalse() for inverse)")
For a more comprehensive message that spans multiple lines, use
appended(details: String)
instead:
// produces "expected to be true, got <actual>\n\nuse beFalse() for inverse\nor use beNil()"
// details do not show inline in Xcode, but do show up in test logs.
.expectedActualValueTo("be true").appended(details: "use beFalse() for inverse\nor use beNil()")
Asynchronous Predicates
To write predicates against async expressions, return an instance of
AsyncPredicate
. The closure passed to AsyncPredicate
is async, and the
expression you evaluate is also asynchronous and needs to be awaited on.
// Swift
actor CallRecorder<Arguments> {
private(set) var calls: [Arguments] = []
func record(call: Arguments) {
calls.append(call)
}
}
func beCalled<Argument: Equatable>(with arguments: Argument) -> AsyncPredicate<CallRecorder<Argument>> {
AsyncPredicate { (expression: AsyncExpression<CallRecorder<Argument>>) in
let message = ExpectationMessage.expectedActualValueTo("be called with \(arguments)")
guard let calls = try await expression.evaluate()?.calls else {
return PredicateResult(status: .fail, message: message.appendedBeNilHint())
}
return PredicateResult(bool: calls.contains(args), message: message.appended(details: "called with \(calls)"))
}
}
In this example, we created an actor to act as an object to record calls to an
async function. Then, we created the beCalled(with:)
matcher to check if the
actor has received a call with the given arguments.
Supporting Objective-C
To use a custom matcher written in Swift from Objective-C, you’ll have
to extend the NMBPredicate
class, adding a new class method for your
custom matcher. The example below defines the class method
+[NMBPredicate beNilMatcher]
:
// Swift
extension NMBPredicate {
@objc public class func beNilMatcher() -> NMBPredicate {
return NMBPredicate { actualExpression in
return try beNil().satisfies(actualExpression).toObjectiveC()
}
}
}
The above allows you to use the matcher from Objective-C:
// Objective-C
expect(actual).to([NMBPredicate beNilMatcher]());
To make the syntax easier to use, define a C function that calls the class method:
// Objective-C
FOUNDATION_EXPORT NMBPredicate *beNil() {
return [NMBPredicate beNilMatcher];
}
Properly Handling nil
in Objective-C Matchers
When supporting Objective-C, make sure you handle nil
appropriately.
Like Cedar,
most matchers do not match with nil. This is to bring prevent test
writers from being surprised by nil
values where they did not expect
them.
Nimble provides the beNil
matcher function for test writer that want
to make expectations on nil
objects:
// Objective-C
expect(nil).to(equal(nil)); // fails
expect(nil).to(beNil()); // passes
If your matcher does not want to match with nil, you use Predicate.define
or Predicate.simple
.
Using those factory methods will automatically generate expected value failure messages when they’re nil.
public func beginWith<S: Sequence>(_ startingElement: S.Element) -> Predicate<S> where S.Element: Equatable {
return Predicate.simple("begin with <\(startingElement)>") { actualExpression in
guard let actualValue = try actualExpression.evaluate() else { return .fail }
var actualGenerator = actualValue.makeIterator()
return PredicateStatus(bool: actualGenerator.next() == startingElement)
}
}
extension NMBPredicate {
@objc public class func beginWithMatcher(_ expected: Any) -> NMBPredicate {
return NMBPredicate { actualExpression in
let actual = try actualExpression.evaluate()
let expr = actualExpression.cast { $0 as? NMBOrderedCollection }
return try beginWith(expected).satisfies(expr).toObjectiveC()
}
}
}
Installing Nimble
Nimble can be used on its own, or in conjunction with its sister project, Quick. To install both Quick and Nimble, follow the installation instructions in the Quick Documentation.
Nimble can currently be installed in one of two ways: using CocoaPods, or with git submodules.
Installing Nimble as a Submodule
To use Nimble as a submodule to test your macOS, iOS or tvOS applications, follow these 4 easy steps:
- Clone the Nimble repository
- Add Nimble.xcodeproj to the Xcode workspace for your project
- Link Nimble.framework to your test target
- Start writing expectations!
For more detailed instructions on each of these steps, read How to Install Quick. Ignore the steps involving adding Quick to your project in order to install just Nimble.
Installing Nimble via CocoaPods
To use Nimble in CocoaPods to test your macOS, iOS, tvOS or watchOS applications, add
Nimble to your podfile and add the use_frameworks!
line to enable Swift
support for CocoaPods.
platform :ios, '8.0'
source 'https://github.com/CocoaPods/Specs.git'
# Whatever pods you need for your app go here
target 'YOUR_APP_NAME_HERE_Tests', :exclusive => true do
use_frameworks!
pod 'Nimble'
end
Finally run pod install
.
Installing Nimble via Swift Package Manager
Xcode
To install Nimble via Xcode’s Swift Package Manager Integration:
Select your project configuration, then the project tab, then the Package
Dependencies tab. Click on the “plus” button at the bottom of the list,
then follow the wizard to add Quick to your project. Specify
https://github.com/Quick/Nimble.git
as the url, and be sure to add
Nimble as a dependency of your unit test target, not your app target.
Package.Swift
To use Nimble with Swift Package Manager to test your applications, add Nimble
to your Package.Swift
and link it with your test target:
// swift-tools-version:5.5
import PackageDescription
let package = Package(
name: "MyAwesomeLibrary",
products: [
// ...
],
dependencies: [
// ...
.package(url: "https://github.com/Quick/Nimble.git", from: "12.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "MyAwesomeLibrary",
dependencies: ...),
.testTarget(
name: "MyAwesomeLibraryTests",
dependencies: ["MyAwesomeLibrary", "Nimble"]),
]
)
Please note that if you install Nimble using Swift Package Manager, then raiseException
is not available.
Using Nimble without XCTest
Nimble is integrated with XCTest to allow it work well when used in Xcode test bundles, however it can also be used in a standalone app. After installing Nimble using one of the above methods, there are two additional steps required to make this work.
- Create a custom assertion handler and assign an instance of it to the
global
NimbleAssertionHandler
variable. For example:
class MyAssertionHandler : AssertionHandler {
func assert(assertion: Bool, message: FailureMessage, location: SourceLocation) {
if (!assertion) {
print("Expectation failed: \(message.stringValue)")
}
}
}
// Somewhere before you use any assertions
NimbleAssertionHandler = MyAssertionHandler()
- Add a post-build action to fix an issue with the Swift XCTest support
library being unnecessarily copied into your app
- Edit your scheme in Xcode, and navigate to Build -> Post-actions
- Click the “+” icon and select “New Run Script Action”
- Open the “Provide build settings from” dropdown and select your target
- Enter the following script contents:
rm "${SWIFT_STDLIB_TOOL_DESTINATION_DIR}/libswiftXCTest.dylib"
You can now use Nimble assertions in your code and handle failures as you see fit.


|
Financial Donations
There are two easy ways to donate to our team:
1) We are happy to accept checks sent to Ballard Viking Robotics, 1418 NW 65th St, Seattle, Wa 98117, made out to FIRST Washington with "FRC 2928" in the memo. We will record you and/or your company’s information when received.
2) Tax deductible donations can be made through FIRST Washington online.
Click on the green Donate button on the top right.
Fill out the form.
Make sure you direct the donation to FRC Team 2928
Supplies and In-kind Donations
Building materials and meals are welcome!
|


Hey everyone, my name is Steven! I'm a Development Analyst leveraging a bachelor’s degree in Economics/Computer science in addition to a completed six-month Full Stack application bootcamp in order to bring both people and technical skills together.
Some examples of my personal projects are listed below, which are a mix of mainly Javascript, SQL, MongoDB, Express, Node.JS and React.

A basic, barebones CRUD application that demonstrates the use of the Mongoose ORM and the basic HTTP methods including PUT, POST, DELETE, GET. Using the Postman web API testing application I was able to show the succesful connection from the cloud based MongoDB database to the routes and endpoints specified.
Using React, Javascript, Node.js, and HTML I've made a memory game. Click on each picture only once. Get all the pics before you click any one twice or you will have to start over!
An Amazon-like CLI application that demonstrates the use of Node.js and SQL. This project utilies a variety of npm packages including inquirer, mySQL and the CLI-Table package. The app will take in orders from customers and deplete stock from the store's inventory. The changes will be reflected in the console table that has been formatted with the CLI table npm package. Table header color has been changed to green..
Completed the Elements of Computing Certificate in place of a minor
6 month intensive program covering topics from front to back end web technology and coding. Areas of focus included the MERN Stack and both sql and nosql databases.
-Participates in development of the architecture, design, and Health Plan data integration between the Health Plan, its vendors and HHSC. This includes regulatory data exchanges as well as operational exchange processes. The Data Integrity Analyst will write and modify computer code in applicable programming languages (C#/SQL/.Net) in both batch and on-line modes; prepare test data and test programs to eliminate errors in logic or coding; analyze and corrects system performance problems during the test phase.
-In charge of processing membership updates,applications and payments through the TCTA database. -Client Service communications and Excel documentation -Large scale payment balancing alongside accounting support and business to business phone communication
-Verifies purchase requisitions by comparing items requested to master list; clarifying unclear items; recommending alternatives and establishing positive vendor/client relationships. -Uses quickbooks to analyze inventory management and manage large scale orders that can exceed $50,000 per order. -Establish connections with overseas Vendors and Customs Agents to ensure the smooth delivery of shipping containers to the US. Constantly in contact with every individual in the supply chain while material is being shipped from Vietnam, Turkey, Mexico and Morocco. -Forwards available inventory items by verifying stock; scheduling delivery. -Prepares purchase orders by verifying specifications and price; obtaining recommendations from suppliers for substitute items; obtaining approval from requisitioning/sales department.


Progress stepper tests
This stepper example is to help resolve the AMI Make a payment stepper and uses the Kendo stepper as a starting point.
Example 01: Step 1 active
You are currently on step 1 of 3. Search
Step 2 of 3. Confirm your details. Not completed.
Step 3 of 3. Make a payment. Not completed.
Code

Search
You are currently on step 1 of 3. Search

Confirm
Step 2 of 3. Confirm your details. Not completed.

Pay
Step 3 of 3. Make a payment. Not completed.

Example 02: Step 2 active
Step 1 of 3. Search. Completed
You are currently on step 2 of 3. Confirm your details.
Step 3 of 3. Make a payment. Not completed.
Code

Search
Step 1 of 3. Search. Completed

Confirm
You are currently on step 2 of 3. Confirm your details.

Pay
Step 3 of 3. Make a payment. Not completed.

Example 03: Step 3 active
Step 1 of 3. Search. Completed
Step 2 of 3. Confirm your details. Completed
You are currently on step 3 of 3. Make a payment.
Code

Search
Step 1 of 3. Search. Completed

Confirm
Step 2 of 3. Confirm your details. Completed

Pay
You are currently on step 3 of 3. Make a payment.


|
Home >
Enterprise >
Participants >
Elastic > APT3 Configuration
|
Endgame Configuration
Product Versions
Version 3.0.2
Description
The Endgame platform is a centrally managed single agent solution that unifies prevention, detection, response, and threat hunting to stop attacks. It delivers layered signatureless preventions, deep, contextualized visibility into endpoint events, and a rich set of response capabilities in a single lightweight agent. It is driven by a scalable and easy-to-use on-prem or SaaS management platform and supports easy integration with other tools through a fully documented API.
The Endgame agent takes seconds to deploy and is very lightweight, with < 1% overall system impact and average CPU Usage of < 2%. It monitors the endpoint in real time, providing real-time prevention to keep threats out and rich data collection and intelligent automation to streamline triage, hunting, and response. Cloud is optional; offline or enclaved endpoints are equally protected.
Endgame's high confidence, layered, signatureless protections cover the entire attacker lifecycle, mapped to ATT&CK. Kernel Behavioral Preventions operate in-line at the lowest level, blocking techniques like exploits, process injection, credential dumping, token theft, and more. Endgame's third-party validated, lightweight static and dynamic models block 99%+ of malware, malicious macro-enabled documents, and ransomware before damage can take place. Endgame's tradecraft protections monitor system activity in real-time, alerting on techniques across all tactics in ATT&CK with very high confidence. These behavioral protections operating in unison provide high confidence that breaches of all kinds will be blocked or detected very early.
No product will prevent 100% of all breaches, and because attackers often impersonate normal users, no product can alert across the full depth of ATT&CK without creating massive false positives in production. Deep visibility with long retrospective lookback is necessary to hunt for and respond to threats that get through the extensive protection layers. Endgame provides the visibility needed by hunters and responders, collecting, enriching, contextualizing, and making available endpoint telemetry data like process executions, domain lookups, TCP connection information, and much more. Endgame's collection sources are hardened and very difficult for adversaries to blind, a growing problem in endpoint security. Endgame's unique hybrid endpoint/cloud architecture provides the longest lookback in the industry (approximately 180 days by default) and flexible event forwarding to the Endgame cloud and/or a customer's SIEM/data lake for further enrichment.
Hunters can access the data flexibly. Sophisticated users with deep knowledge of attacker behaviors can write simple queries using Endgame's powerful Event Query Language to ask any possible security relevant question. Less experienced users are able to use the Artemis natural language query interface and baked in investigations to hunt without needing years of experience and training to make an impact.
Endgame users can easily interact with alerts and query results through Resolver, a graphical, interactive UI which describes the full extent of an attack and allows for rapid single-click response, or through the robust Endgame Shell. Endgame provides a rich set of response actions such as file quarantine, host isolation, file retrieval or deletion, process memory dumps, and more, in most cases eliminating the need for responders to bring in other tools.
Configuration
Default Threat Hunting Policy (in Detect-Only mode, per test criteria)


I design with the empathy brought from my previous career as a journalist. My work experience focused on transforming complex data and workflow into intuitive interface and solving problems with design thinking.
As a UX designer, what makes me feel excited is exploring the solution and proposing various design ideas to solve users' problems and make their work and life easy.
I came to UX from a journalism background, hoping to make people’s lives better with technology. My experience of investigating and interviewing as a journalist now helps me empathize users and identify problems in the user-centered design process.
After graduating from the HCI program at the University of Michigan, I worked as a UX designer at Deloitte Consulting. I had opportunities to solve complex problems in various fields (e.g. Tax, Finance, and Healthcare) with design thinking and became more professional in producing design artifacts and iterating rapidly.


Describe Images Request. More...
Public Member Functions | |
| (id) | - init |
| Default constructor for a new object. | |
| (void) | - addFilter: |
| Adds a single object to filters. | |
| (NSString *) | - description |
| Returns a string representation of this object; useful for testing and debugging. | |
Properties | |
| NSMutableArray * | imageIds |
| An optional list of the AMI IDs to describe. | |
| NSMutableArray * | owners |
| The optional list of owners for the described AMIs. | |
| NSMutableArray * | executableUsers |
| The optional list of users with explicit launch permissions for the described AMIs. | |
| NSMutableArray * | filters |
| A list of filters used to match properties for Images. |
Describe Images Request.
| - (void EC2DescribeImagesRequest.)addFilter: | (EC2Filter *) | filter |
Adds a single object to filters.
This function will alloc and init filters if not already done.
| - (NSString * EC2DescribeImagesRequest.)description |
Returns a string representation of this object; useful for testing and debugging.
| - (id EC2DescribeImagesRequest.)init |
Default constructor for a new object.
Callers should use the property methods to initialize this object after creating it.
- (NSMutableArray *) executableUsers [read, write, retain] |
The optional list of users with explicit launch permissions for the described AMIs.
The user ID can be a user's account ID, 'self' to return AMIs for which the sender of the request has explicit launch permissions, or 'all' to return AMIs with public launch permissions.
- (NSMutableArray *) filters [read, write, retain] |
A list of filters used to match properties for Images.
For a complete reference to the available filter keys for this operation, see the <a "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/">Amazon EC2 API reference.
- (NSMutableArray *) imageIds [read, write, retain] |
An optional list of the AMI IDs to describe.
If not specified, all AMIs will be described.
- (NSMutableArray *) owners [read, write, retain] |
The optional list of owners for the described AMIs.
The IDs amazon, self, and explicit can be used to include AMIs owned by Amazon, AMIs owned by the user, and AMIs for which the user has explicit launch permissions, respectively.


clive boulton
Currently fostering startups, teams and developer communities toward a robust composition of crypto-commerce technologies toward nextgen connected business systems with Hyperledger projects.
Contact MeCurrently fostering startups, teams and developer communities toward a robust composition of crypto-commerce technologies toward nextgen connected business systems with Hyperledger projects.
Contact Me


Neolithic Marathon
Avebury => Amesbury ENG
Website: www.wiltshirewildlife.org
Race Winners
(27 runnings)
06 May
2007
30 Apr
2006
01 May
2005
02 May
2004
04 May
2003
05 May
2002
2001
30 Apr
2000
1999
1998
1997
1996
07 May 1995
07 May
1994
1993
03 May
1992
05 May 1991
1990
1989
Notes: 1989 was the inaugural year.
30 Apr
2017
---
cancelled for reasons unknown
---
cancelled for reasons unknown
01 May
2016
3:06:40
C Sandison (ENG)
3:24:31
Karen Hacker (ENG)
03 May
2015
3:10:47
C MacLean (ENG)
3:28:15
J White (ENG)
04 May
2014
2:51:35
Scott Forbes (ENG)
3:17:19
Samantha Kelly (ENG)
05 May
2013
2:51:53
John Ward (ENG)
3:25:54
J Lewis (ENG)
06 May
2012
2:56:50
Paul Jegou (ENG)
3:40:31
J Green (ENG)
01 May
2011
2:55:58
K Garbutt (ENG)
3:37:07
M Powell (ENG)
02 May
2010
2:53:04
C James-2
---
n/a
03 May
2009
2:57:40
C James (GBR)
3:39:25
B Browne (GBR)
04 May
2008
2:57:53
A James (GBR)
3:22:34
J Clayton (GBR)
2:51:06
Matthew Lynas (40,ENG)
3:26:14
L Cummings-2
2:58:08
James Maybery (GBR)
3:30:43
Zoe Rooke (ENG)
2:46:20
Nathan Montague (ENG)
3:27:55
Alison Vuagniaux (ENG)
2:50:10
T Hazell (ENG)
3:19:40
L Cummings (ENG)
---
n/a
---
n/a
2:43:39
Dennis Walmsley (ENG)
3:02:52
Maggie Horton (ENG)
---
probably cancelled (hoof & mouth)
---
probably cancelled (hoof & mouth)
---
n/a
---
n/a
---
n/a
---
n/a
---
n/a
---
n/a
---
n/a
---
n/a
---
n/a
---
n/a
2:50::
Robin Gardiner (ENG)
---
Dawn Kenwright (WAL)
---
n/a
---
n/a
---
n/a
---
n/a
---
n/a
---
n/a
2:37:24
Gwyn Williams (WAL)
3:34:28
J Roberts (ENG)
---
n/a
---
n/a
---
n/a
---
n/a
Most Wins
(1986/date)
Men
3
Dan Martin (IL/USA)
1996,2000,2006
Matthew Simpson (IL/USA)
1993-94,2009
Women
2
Sheila Rickleffs (WI/USA)
1987-88
.
Theresa Ann Arion (MN/USA)
2000-01
Prize Money
No information on prize money has been received for this race.
Race Time Bias
Insufficient data to calculate the race time bias.
Competitive Level
Insufficient data to calculate the competitive level.
Quality Performances
Men No men under 2:20 Women No women under 2:50
Last Updated on 12 Dec 2017
Contributors: Andy Milroy (2), Ian Champion (3), Paul Michiels (1), Mick McGeoch (15)


Find DataFunctions that can be used to find data |
|
|---|---|
Find nearest stations using a point's coordinates |
|
Download tablesFuntions that retrieve tibbles with Hydroscope’s data for a given data source |
|
|
|
Get tibbles from Hydroscope |
Download time seriesRetrieve a tibble with time series’ values from Hydroscope |
|
Get time series values in a tibble |
|
Miscellaneous functionsInternal functions and helpers |
|
Convert coordinates from Hydroscope's points to a tibble |
|
Translate Greek names and terms to English |
|
DatasetsThe internal datasets of the package |
|
Greek borders |
|
stations |
|
timeseries |


| About Dailyrotten |
|
Feedback
If you like this page, hate it, or would like to suggest changes,
<EMAIL_ADDRESS>is listening. This page
is experimental and somewhat different from what we usually offer, so please
do send your feedback.
Adding Stories
If you are a rotten newshound and you would like to suggest a story,
visit our submit page to
send us the URL. Stories that are accepted will have your name credited.
Posting Comments
In order to post comments to stories, you will have to
create an account.
Accounts will generally be validated within 24 hours, and of
course will be disabled if there is abuse.
Viewership
On the first full day this page went live, 100,000 people visited this Rotten
News page. Of course that was the day after the WTC attacks, so that number is
somewhat distorted. Right now this page gets between 50,000 and 75,000 people
every day.
Linking
We encourage everyone to link to this page; if you like it, others probably
will as well.
Other Rotten
Rotten
Gaping Maw
Celebrity Morgue
Mugshots
Rotten Store
Rate My Poo
Rate My Kitten
Rate My Finger
Penny Postcards
Phallic
Boners
Home
Make Dailyrotten your start page
|
|
|
June 08, 2002
Sentenced to wallow in their own filth
Naples Daily News | Submitted by: anonymous
"The Rosses pleaded guilty to the charge Thursday by admitting to the
violations.  However, the
judge withheld a formal finding of guilt, finding the violations
weren't "material or substantial"...  The older boy, home
alone, was sitting in a chair in the living room and was covered
with bugs."
|
|
Read article...
|
|
Man to smoke pot legally in jail
CBC New Brunswick | Submitted by: m_wil
"Public safety minister Margaret Anne Blaney says having an inmate with
the right to smoke marijuana is a first for the province. She says the
province doesn't have a policy for this situation but will have to
come up with one before July 18."
|
|
Read article...
|
|
Big Brother dons a snorkel
AZ Central | Submitted by: Orpheus
"The FBI has begun a nationwide canvass of shops that offer scuba diving instruction based on information that "various terrorist elements have sought to develop an offensive scuba diver capability." First scuba shops, then your own home. Big Brother watches all.
|
|
Read article...
|
|
Girls are still rotten
Boulder Weekly | Submitted by: anonymous
Though we've known it all along, a number of books about how rotten
girls can be are getting attention on bestseller lists.
|
|
Read article...
|
|
Bad Times for G-Men
Miami Herald | Submitted by: Purple Thunderbolt of Spode
I want my client to be judged by a jury of his homeboy peers...
so I insist that Your Honor reject all potential jurors whose name
begins with the letter "G" because (this being Miami) that person
is likely to be a Hispanic and therefore unsympathetic to my twice
convicted drug dealing gun waving low life client.
|
|
Read article...
|
|
Nazi's heirs lose battle over Hitler watercolors
Independent | Submitted by: george_lazenby
"Artistically they are of scant merit, said by those who have seen
them to depict street scenes and war landscapes. But as the
hilarious 1983 saga of the fake Hitler diaries shows, any artifact
carrying the signature 'A. Hitler' has a curiosity value beyond price."
|
|
Read article...
|
|
Kiddie Kommandos go on rampage
Delco Times | Submitted by: Crazy Quagga
Armed service recruitment ads are on TV and in schools. The media,
especially after 9-11, regularly glamorizes the military. So it should
come as no surprise that all this propaganda would brainwash a bunch
of stupid 14-year-olds into forming their own "Bravo Team" and then
break into their middle school armed with pellet guns and doing
$40-$50,000 worth of damage.
|
|
Read article...
|
|
Maryland state tree bites the dust
CNN | Submitted by: McUSA
"The massive Wye Oak, the living symbol of Maryland's state tree and
designated the largest white oak in the country, was toppled Thursday
during a thunderstorm." Contains a graphic photo that may be disturbing
to some of our arboreal viewers.
|
|
Read article...
|
|
Town celebrates axe murder
Newsday | Submitted by: Hail Otis
"In addition to the movie, the Villisca Ax Murders 90th Anniversary
Commemorative Weekend also includes a panel discussion led by history
professors, tours of the restored Moore house, walking tours of the
town and cemetery and a dinner to raise money for the public library.
Carolyn Gage, editor of the Villisca Review, said the challenge in
planning the weekend was avoiding any hint of exploitation."
|
|
Read article...
|
|
Police kill dog for spite
MSNBC | Submitted by: pete the anarchist
"I think it was uncalled for the way these cops acted yesterday... no need
for people to get Maced in the face and thrown against the ground, shooting
the dog for no reason when the dog didn't do nothing to anyone. He was a
harmless dog." According to a witness, "The officer had his knee in his
back on top of Terry while the other officer had his gun out pointing
at the dog." Bang.
|
|
Read article...
|
|
Transexual Minister in Methodist Church
Washington Post | Submitted by: Incubus
United Methodist Bishop Felton May said he intends to assign a minister who
recently had a sex-change operation to a pastoral position, the first such
appointment in the local church and one of the few in any mainline denomination
in the country. Some Methodists oppose the appointment for moral and
theological reasons and are trying to derail it on procedural grounds."
|
|
Read article...
|
|
Rampage to coverup mummification murders
KNBC-TV 4 Los Angeles | Submitted by: Helaine the Pain
"A gunman may have staged a deadly grocery store rampage out of fear
that someone was about to find his parents' mummified bodies in his home,
police said Friday... A bloodstained carpenter's hammer was found next to
the bed and apparently had been used to kill them two years ago, police
said in a statement. Investigators also found several Polaroid
photographs of the decomposed bodies, dated April 2001."
|
|
Read article...
|
|
Bo and Luke Duke in SUV
Denver Post | Submitted by: marcus
A couple of humanity's finest, liquored up to paint the town red decide to fly their Ford Explorer over a classic car show. Despite the fact they did clear a 2 seater hotrod does not mean they are in Hazzard County anymore. These Good ole boys are going to spend a few years in jail.
|
|
Read article...
|
|
Parents name kid after hockey stadium
WDIV-TV 4 Detroit | Submitted by: Nben
"A Toledo couple has showed their devotion to the Detroit Red Wings by
naming their newborn son Joe Louis Arena. "We were watching the game and
saw Joe Louis Arena on the ice ... in the middle ... and you're always
thinking your last name when you see "arena," so we said we'd name him
Joe Louis Arena and it stuck," said Sarah Arena, the baby's mother."
They let anyone be a parent nowadays.
|
|
Read article...
|
|
Man gets life for baking pot brownies
San Diego Union-Tribune | Submitted by: Kyle T.
"Prosecutors also charged Wells with child abuse, saying he harmed his
son when he gave him the marijuana, but Superior Court Judge Marguerite
Wagner dismissed that charge. "I'm not convinced it causes great bodily
injury for a 15-year-old to have a (laced) brownie," she said."
|
|
Read article...
|
|
West Virginia police at their finest
Charleston Daily Mail | Submitted by: Crime Dog
"The substance that 37-year-old Kelley Mace was accused of possessing
turned out to be plant food, her lawyer said Friday...
On the day that police raided Mace's home, Patton said the Clay county
informant started calling his client at about 10 a.m. and harassing her...
"He was laughing and telling her that the cops were coming," Patton said.
"That kept up all day. When she'd ask what he was talking about, he'd
just tell her ‘You'll see.'" Well, it is West Virginia. Duh.
|
|
Read article...
|
|
Dead Sox newest fantasy league team
Court TV | Submitted by: Son of Benway
"Fantasy Death Row, which bills its site as "Capital Fun-ishment from
the heart of Texas," is a different sort of contest — quite literally
a game of life and death. Participants select "players" from a list of
death row inmates, then accumulate points based on the progress of
their cases. Pardons are worth 50 points, clemency 25 points, and players lose
10 points if an inmate is executed and another 50 if the executed inmate is
proven not guilty after his death." This all seems backwards.
|
|
Read article...
|
|
South Africa internet may be forced down
ZDnet | Submitted by: Soylent
"South Africa's parliament gave initial approval Friday to a law designed
to expand access to the Internet, but critics say it could force the network
to shut down in the country...
"This bill fails to avert the danger that we will lose South Africa's major
connection to the Internet itself... This Net grab simply nationalizes domain
name administration," she said before voting against it."
|
|
Read article...
|
|
|
|
|


Traffic Density
Jhansi Railways
Kanpur Jhansi Highway NH27
Elite choraha
Biet Main Road
Jawalior road


This story is actually about a friend of mine (G) who suffered from acute depression, and had a long history of depression and suicide attempts in his family. He is extremely chemically dependant, as both his parents formerly were.
  I got the thirty five bucks and then called up the dude I got the quarter from, said it was a little skimpy, and asked him to sell me a half for 35.
There were about eight of us smoking, and since I was packing for the time being, they made me smoke a bowl out of the bong to myself. Then we proceeded to smoke most of the half, and found that it is the most potent shwag/mec that I have ever smoked. I had no problem smoking a lot of it cause it was so cheap.
My friend G, the depression guy, got higher than any of us. He also gets depressed when really high. He went home and decided to take two bottles of tylenol, 48 pills. I woke from a deep slumber to G's roomate calling and wanting to know if G took any acid or shrooms or anything, because G was puking red and delirious. I said get him to a hospital fast, and found out about the whole incident the next day.
 Anyone smart would see this as a cue to stop, but the day he was out of the hospital he took to smoking cigarettes again. The first time I saw him once he was out of the hospital, he was drinking. Two days later, he was smoking pot again.  He is now back to smoking tons, and I have no doubt that he will kill himself one of these days.
Experience Reports are the writings and opinions of the individual authors who submit them.
Some of the activities described are dangerous and/or illegal and none are recommended by Erowid.


Classes
Handles the ajax calls made to backend from the Full Calendar
Purpose of this class is to source out events
that are page versions in disguise. It also handles
updating a page version event if the user has changed
it on the front end calendar .
A source is a plage to fetch events given a start and
end time. Our CalendarResponseHandler will use the
PageVersionSource (and others possibly later) so I
made an interface we can all abide by if we need to
create more event sources for the full calendar
This class loads all the providers in other folders for
all of devise. We don't want the developer to have to load
10 different service providers to work with devise, so
this class is just a wrapper to load all of the service
providers instead of having to load 10 individual ones in
the app/config/app.php file
Language detector is used to determine the current and
universal languages for this system. It uses LocaleDetector
to get the universal code, i.e 'en', 'es', and then fetches
the DvsLanguage from the database
The languages manager allows us to manage
the all things related to DvsLanguage model
The langauges repository provides methods to
fetch rows in the context of DvsLanguage model
Handles responses for language routes. This class
is likely used as a responsepath to a dvspage
field.
Locales are shorthand 2 letter strings
for a language/region.
Class CategoryAlreadyExistsException is thrown
whenever the Categories/Manager finds a duplicate
category. (If you try to create the same directory)
Class CategoryPaths converts dot paths to real paths
and also finds server paths and browser urls to the configured
root media directory where all our media files are stored at.
Class Manager manages categories. A category is basically
a directory inside of the /media folder.
Class ResponseHandler handles the controller side
of managing categories. These methods are likely
referenced in dvs_pages table
Registers a new devise.video.encoder we can use
globally throughout Laravel
Class InvalidEncodingSettingsException is thrown in ZencoderJob
anytime invalid settings are passed in when trying to create a
new Zencoder api call to start encoding videos
Class ZencoderJob handles incoming requests that have been
completed by Zencoder. Also pushes requests to Zencoder api.
Class ZencoderNotificationsController handles incoming requests
from the zencoder server when it is finished encoding our videos
in order to let us know it is time to download the encoded video
back to our own servers
Class FileDownloader downloads a file from
the internet and saves it into a specified directory
Class Filesystem inherits from Illuminate\Filesystem\Filesystem
but adds some additional functionality such as file searching.
Class InvalidFileException is thrown in MediaPaths
whenever the file path given is not valid (it doesn't exist)
Class Manager
Class Repository builds a complex array of data around the file structure
of the media manager. This let's us fetch a lot of things regarding the
file system around the media manager
Class ResponseHandler handles controller part of media manager
as far as uploading, renaming and removing media files goes
Class Manager takes care of image management. This lets us
get a list of images and also crop and resize images
Class ResponseHandler handles requests (controller/route)
made to crop images
Class MediaPaths abstracts away paths that we can use
and also has a few helper methods for other classes to use
Class MenusRepository retrieves things related to
DvsMenu and DvsMenuItems database table
Class MenusResponseHandler is used to store and update menus
and menu items in the database. There is likely a dvs_pages
database row pointing to these two methods.
Class MigrationScaffolding
Class SanityChecksHelper
Class ScaffoldingManager
Class ScaffoldingResponseHandler
Class SeederScaffolding
Class TemplateScaffolding
Class BaseScaffolding
Class CrudScaffolding
Class ApiPagesManager manages the creating of new pages,
updating pages
Class ApiPagesRepository is used to retrieve DvsPage models of Function type
Response handler takes care of creating,updating, destroying
This classes purpose is to act as a container
for fields on the collection level. A collection
can have multiple fields, e.g.
Collection fields are objects that allow
us to traverse the keys in that collection.
Manage collections in the database by creating, updating
and removing them.
Retreives collection instances and sets and fields for us.
Handle responses for collection instances
Whenever we see a duplicate field key on a page
throw an exception for the developer so they can fix it.
A field manager has the responsibilty of managing fields in
the database.
Field value is an object that holds json
values for a DvsField model
Fields repository allows us to retrieve fields
that belong to page versions and keys and have been
deleted. We also can find global fields with this
repository.
When the video field is updated we will
call this class to handle the encoding part
This should be registered in the Events of
laravel whenever the PagesServiceProvider starts
This class should be registered in a service provider
for PagesServiceProvider. It is called anytime a
field with type "image" is updated. We do this so we
can hook into the updated event and then create media
versions and thumbnails for this image field
When the video field is updated we will
call this class to handle the encoding part
This should be registered in the Events of
laravel whenever the PagesServiceProvider starts
Field value is an object that holds json
values for a DvsField model
This class merely decorates the another compiler
and thus giving us the extra functionality we need
to work properly.
purpose of this class is to add placeholder tags
and also rename devise tags and lastly append on
App::make('dvsPageData')->bindings for devise tags,
collections, models and model creators
A storage container class that stores collections and fields
for a given page. These fields and collections are addeded
to a singleton registered in Devise\Pages\PagesServiceProvider.php
called 'dvsPageData'. ALl blade views that contain fields and/or
collections will use methods like addCollection and addField respectively
to add in the data. Eventually all this data is spit out as JSON
for the javascript library in devise to take over from there.
This exception is thrown anytime there are multiple devise
fields on a page that share the same key. Keys are unique to
the page.
This exception is thrown anytime the devise key is
invalid. A invalid variable name in php is considered
an invalid key name. We have to use key name in
php to referrence the devise key, i.e. $keyName->text
Thrown whenever the devise tag is malformed.
Thrown whenever the model tag has no picks, resulting
in a zero count mapping inside the TagManager
Thrown whenever the page is not initialized with
correct data. This should never happen unless
we have bugs in our code.
This visitor class handles putting
this creates two sections, one for devise editors
and the other a pristine section which removes
all the data-devise stuff.
Create and find tags in the database. A tag could be a model, field,
attribute, model creator or collection
Class ViewOpener opens a view for an include statement in this format:
All pages registered in dvs_pages database table
come through this controller show method. The reason
for this is so that the database can be in charge of
the routes and a non developer can construct new
pages with predefined templates in a dropdown selectbox.
Class PageManager manages the creating of new pages,
updating pages and removing and copying pages.
This exception is thrown whenever the page is not found
in the database (likely because the page is not published)
Response handler takes care of creating,updating, destroying
and copying pages within the /admin/pages routes
Class PageVersionManager manages all things page versions related.
Class PageVersionsRepository is used to search and retrieve
DvsPageVersion models and things in context of a Devise Page Versions.
This exception is thrown whenever there are problems with pages
inside of PagesControllerResponse
Class PagesRepository is used to search and retrieve DvsPage models
and things in context of a Devise Page.
Registers the Pages service provider. This allows us to manage our pages
within the Devise cms. It also provides the ability to scan blade views
and extract out fields and collections which can be loaded in the Devise
Sidebar and maintained by the admin.
This builds the variables that are found in views.php config
for a devise page. It uses a ViewComposer (found in this directory)
to inject in the data that is built using this class.
Purpose of this class is to turn something like this
in the view vars into a parameter value we can use.
Class DeviseRouteConfigurationException is thrown in the case where
devise views.php config has been improperly configured.
View composer here is registered in the
Devise\Pages\PagesServiceProvider.php for all
views that are contained within the views config
file. That is how those views have their data injected
into them properly - by running through this view composer.
Class PageSearch is an example of how you could search
for pages using the SearchableModelTrait
Class Pagination is used so we can paginate search results
from many different searched models
Class SearchableModelTrait can be applied to an eloquent model
to give it "searchablity". You have to override the getColumns method
and/or make a
protected $searchable = array('column1' => 1, 'column2' => 2);
Class UniversalSearch lets us register new searchable models
and then search through all of them
Class DeviseUniversalSearchProvider registers the universal
searching mechanism for Devise
SettingsManager is used to update the config overrides file
which allows an admin to override any config variable in devise
Class FileManager is used to manage retrieving and modifying
Devise config(s) files along with any other management functions
SettingsManager is used to update the config overrides file
which allows an admin to override any config variable in devise
Class DeviseException should be the base class exception
for any exception thrown inside of Devise. This way we can
catch those specifically if we want and know that they are
different from just regular exceptions.
Class DeviseHttpException should be the base class exception
for any exception thrown inside of Devise. This way we can
catch those specifically if we want and know that they are
different from just regular exceptions.
Class DeviseResponse for some reason Illuminate\Support\Facades\Response
is not an actual facade but a real class. So we can't use getFacadeAccessor
on it. Instead we write a proxy class called DeviseResponse which simply
calls static methods on Response object.
This validation exception is thrown
when ever there are validation errors
somewhere. It is used in the Manager class
to assert fields are valid.
Class Framework wraps important components that we
use from Laravel's framework. Components like Config,
Validator, Request, Response.
Class EloquentBuilder is ran on paginate queries only and takes
the liberty of sorting and filtering results for us smartly and
magically.
Class Filter
Class Manager changes the cookie/session keys for multisorts
Class Sort handles creating links and filters for us which
Class SortableFacade
Class SortableServiceProvider registers the Sort facade
on the Laravel container
Class SupportServiceProvider registers support components of
Devise and other helpers that Devise uses.
Class DeviseTemplateNotFoundException is thrown in the case where
devise templates.php config is missing the a view path
Class TemplatesManager manages updating templates,
removing and additional admin functions
Class TemplatesRepository is used to retrieve template data
Class TemplatesResponseHandler is used to retrieve template data
Class GroupManager manages the creating,
updating, and removing of groups.
Class PermissionsManager manages updating permissions,
removing and additional admin functions
Class PermissionsRepository is used to retrieve permission data
Class PermissionsResponseHandler is used to retrieve permission data
Class RedirectHandler handles redirecting
Class RuleList maintains list of built-in and user defined functions (in
permissions-conditions config) which can be checked using DeviseUser Facade.
Class RuleManager manages retrieval, creation/addition, execution
and evaluation of native and user-defined rules.
Class SessionsRepository is used to search and retrieve current DvsUser in session
and things in context of a DvsUser/DvsGroup.
Helper allows specific methods to be easily accessible through
the DeviseUser facade.
Class UserManager manages the creating of new users,
updating existing users and removing users.
Class UserServiceProvider registers the devise user, rulelist and rulemanager
facades
Class UsersRepository is used to search and retrieve DvsUser models
and things in context of a Devise User.
Response handler takes care of user login/logout, creating,
updating, destroying users within /admin/users routes


ReactiveCocoa 1.0.0 Hierarchy
Class Hierarchy
- NSObject
- RACBacktrace
- RACBlockTrampoline
- RACDelegateProxy
- RACDisposable
- RACEvent
- RACEventTrampoline
- RACKVOTrampoline
- RACMulticastConnection
- RACObjCRuntime
- RACScheduler
- RACStream
- RACSubscriber
- RACSubscriptingAssignmentObjectKeyPathPair
- RACSubscriptingAssignmentTrampoline
- RACTuple
- RACTupleNil
- RACTupleUnpackingTrampoline
- RACUnit
- NSValueTransformer
Protocol References
Category References
- NSArray(RACSequenceAdditions)
- NSData(RACSupport)
- NSDictionary(RACSequenceAdditions)
- NSEnumerator(RACSequenceAdditions)
- NSFileHandle(RACSupport)
- NSInvocation(RACTypeParsing)
- NSNotificationCenter(RACSupport)
- NSObject(RACKVOWrapper)
- NSObject(RACKVOWrapperPrivate)
- NSObject(RACLifting)
- NSObject(RACObservablePropertySubject)
- NSObject(RACPropertySubscribing)
- NSOrderedSet(RACSequenceAdditions)
- NSSet(RACSequenceAdditions)
- NSString(RACSequenceAdditions)
- NSString(RACSupport)
- UIControl(RACSignalSupport)
- UITextField(RACSignalSupport)
- UITextView(RACSignalSupport)


|
Mister Spex
1.0
The project Mister Spex is a funny tool to capture images and display them with overlays such as glasses or big red lips over the normal human face. All images can be saved or recorded. Within this software you have three different mode to get the images (LiveView via webcam, Static image and a playback of a recorded video).
|
FaceDetection class. More...
#include <FaceDetection.h>
Public Member Functions | |
| FaceDetection () | |
| Class constructor which creates a new handler. | |
| cv::Mat | detectObjects (cv::Mat &, ImageProcessingSettings, ImageProcessingFlags) |
| Function to detect objects in a given image. In this case face objects. More... | |
| void | cvCreateOverlay (QString, const cv::Mat &, cv::Mat &, cv::Point2i, int) |
| Function to draw a specific overlay on the given image. More... | |
| void | cvCreateOverlayGlasses (QString, const cv::Mat &, cv::Mat &, cv::Point2i, int) |
| Special draw function for the glasses overlay because the special anker point behaviour. More... | |
Private Attributes | |
| double | tem_cropfactor |
| cv::Mat | temp_glass_overlay |
FaceDetection class.
Class has functions for object detection and overlay composing.
| void FaceDetection::cvCreateOverlay | ( | QString | fn, |
| const cv::Mat & | src, | ||
| cv::Mat & | output, | ||
| cv::Point2i | location, | ||
| int | scale | ||
| ) |
Function to draw a specific overlay on the given image.
| fn | an QString name of the overlay file to load. |
| src | an Mat image (OpenCV type) file. |
| output | an Mat image (OpenCV type) file which also contains the overlay. |
| location | an Point2i (OpenCV type for single point with to integers coordinates) which is the anker point of the overlay. |
| scale | an integer value for scaling the overlay according to the image size. |
| void FaceDetection::cvCreateOverlayGlasses | ( | QString | fn, |
| const cv::Mat & | src, | ||
| cv::Mat & | output, | ||
| cv::Point2i | location, | ||
| int | scale | ||
| ) |
Special draw function for the glasses overlay because the special anker point behaviour.
| fn | an QString name of the overlay file to load. |
| src | an Mat image (OpenCV type) file. |
| output | an Mat image (OpenCV type) file which also contains the overlay. |
| location | an Point2i (OpenCV type for single point with to integers coordinates) which is the anker point of the overlay. |
| scale | an integer value for scaling the overlay according to the image size. |
| cv::Mat FaceDetection::detectObjects | ( | cv::Mat & | inMat, |
| ImageProcessingSettings | settings, | ||
| ImageProcessingFlags | drawFlags | ||
| ) |
Function to detect objects in a given image. In this case face objects.
| inMat | an Mat image (OpenCV type) file. |
| settings | an ImageProcessingSettings struct which contains the settings for the area which should be detected |
| drawFlags | an ImageProcessingFlags struct which contains bool values about overlay showing and detection drawing |


@*
* This template takes a single argument, a String containing a
* message to display.
*@
@(message: String)(resID: Int)
@*
* Call the `main` template with two arguments. The first
* argument is a `String` with the title of the page, the second
* argument is an `Html` object containing the body of the page.
*@
@main("Welcome to Play") {
@*
* Get an `Html` object by calling the built-in Play welcome
* template and passing a `String` message.
*@
Add Your Review


[gecode-users] Pruning search in optimisation problems
Malcolm Ryan
malcolmr at cse.unsw.edu.au
Mon Jan 14 00:17:13 CET 2008
I have a question about optimisation. Say I have a constraint system
and I'm trying to minimise the value of some variable X. As I
understand it, the usual approach is to iteratively find a solution
with X = x1, then add the constraint X < x1 and repeat until no more
solutions can be found. Is this correct?
It occurs to me that each iteration only makes the problem more
constrained, so assignments which failed in one iteration will
continue to fail in all subsequent iterations. Is there any standard
way to make use of this information to prune the search?
Malcolm
--
"The act of defending any of the cardinal virtues has today all
the exhilaration of a vice."
- G.K.Chesterton A Defense of
Humility
More information about the gecode-users
mailing list


{{headline}}
{{city}}, {{state}}
{{founders}}
{{industry}}
{{website}}
| DATE | AMOUNT / ROUND | VALUATION | LEAD INVESTOR | INVESTORS |
|---|---|---|---|---|
| {{funding.date}} | {{funding.amount}} | {{funding.valuation}} | {{funding.lead_investor}} | {{funding.investors_count}} |
{{deal.deal_name}} - {{deal.date}}
{{deal.description}}
{{doc.name}}
BOARD MEMBERS
{{member.name}}
INVESTORS
{{member.name}}
EMPLOYEES
{{member.name}}


WSUCon is host to many different types of games. WSUCon isn't really just a LAN party, it's a complete social gaming event. We have 3 different areas set up for all sorts of gaming and we've got tournaments planned that include computer, card, and console games! Participation in WSUCon is based on what you want to do. You can participate in tournaments, have a blast at just gaming by yourself or with friends. It's all up to you!
WSUCon XV - Official Tournaments
You must be registered to participate in official/prized tournaments. Get Excited For Prizes! Everyone is welcome and encouraged to also participate in unofficial ad-hoc tournaments.
Please click on the links below for more information on specific tournaments!
- February 17th: League of Legends @ 7pm - Register here
- February 17th: Super Smash Bros Melee @ 7:30pm - Register through the event registration
- February 17th: Dota 2 @ 9pm - Register here
- February 18th: CS: GO @ 8am - Register here
- February 18th: Overwatch @ 12pm - Register here
- February 18th: Smash 4 @ 1pm - Register through the event registration
What games are going to be played:
Computer Games
- Borderlands
- Terraria
- Dungeons of Dreadmor
- Supreme Commander
- Left 4 Dead 2
- Minecraft
- Half-Life 2: DeathMatch
- Magicka
- Starbound
- Portal
- Runescape?!?
- Warsow
Console Games
- Super Smash Bros: Melee
- Smash 4
- Nidhogg
- Castle Crashers
- Battleblock
- And many more...
Card Games
- Cards Against Humanity
- Magic: The Gathering
- Munchkin
- Dominion
- And many more...
Board/Tabletop Games
- Settlers of Catan
- Mahjong
- Risk
- Pathfinder
- And many more...