File tree Expand file tree Collapse file tree 3 files changed +31
-0
lines changed
IntegrationTests/TestSuites/Sources/PrimaryTests Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -394,3 +394,11 @@ try test("TypedArray_Mutation") {
394394 }
395395 try expectEqual ( toString ( array. jsValue ( ) . object!) , jsStringify ( Array ( 0 ..< 100 ) ) )
396396}
397+
398+ try test ( " Error " ) {
399+ let message = " test error "
400+ let error = JSError ( message: message)
401+ try expectEqual ( error. name, " Error " )
402+ try expectEqual ( error. message, message)
403+ try expectEqual ( error. description, " Error: test error " )
404+ }
Original file line number Diff line number Diff line change 1+ public final class JSError {
2+ private let ref : JSObject
3+ private static let constructor = JSObject . global. Error. function!
4+
5+ public init ( message: String ) {
6+ ref = Self . constructor. new ( [ message] )
7+ }
8+
9+ public var message : String {
10+ ref. message. string!
11+ }
12+
13+ public var name : String {
14+ ref. name. string!
15+ }
16+ }
17+
18+ extension JSError : CustomStringConvertible {
19+ public var description : String { ref. description }
20+ }
Original file line number Diff line number Diff line change @@ -48,3 +48,6 @@ public class JSObject: Equatable {
4848 }
4949}
5050
51+ extension JSObject : CustomStringConvertible {
52+ public var description : String { self . toString!( ) . string! }
53+ }
You can’t perform that action at this time.
0 commit comments