File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed
Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 33if ( ! Object . hasOwnProperty ( 'name' ) ) {
44 Object . defineProperty ( Function . prototype , 'name' , {
55 get : function ( ) {
6- var name = this . toString ( ) . match ( / ^ \s * f u n c t i o n \s * ( \S * ) \s * \( / ) [ 1 ] ;
6+ var matches = this . toString ( ) . match ( / ^ \s * f u n c t i o n \s * ( \S * ) \s * \( / ) ;
7+ var name = matches && matches . length > 1 ? matches [ 1 ] : "" ;
78 // For better performance only parse once, and then cache the
89 // result through a new accessor for repeated access.
910 Object . defineProperty ( this , 'name' , { value : name } ) ;
Original file line number Diff line number Diff line change 1+ library angular2.test.core.dom.shim_spec;
2+
3+ main () {
4+ // not relevant for dart.
5+ }
Original file line number Diff line number Diff line change 1+ import {
2+ AsyncTestCompleter ,
3+ beforeEach ,
4+ ddescribe ,
5+ describe ,
6+ el ,
7+ expect ,
8+ iit ,
9+ inject ,
10+ it ,
11+ xit
12+ } from 'angular2/test_lib' ;
13+
14+ export function main ( ) {
15+ describe ( 'Shim' , ( ) => {
16+
17+ it ( 'should provide correct function.name ' , ( ) => {
18+ var functionWithoutName = function ( _ ) { } ;
19+ function foo ( _ ) { } ;
20+
21+ expect ( ( < any > functionWithoutName ) . name ) . toEqual ( '' ) ;
22+ expect ( ( < any > foo ) . name ) . toEqual ( 'foo' ) ;
23+ } ) ;
24+
25+ } ) ;
26+ }
You can’t perform that action at this time.
0 commit comments