@@ -22,7 +22,7 @@ suite.addBatch({
2222 } ) ;
2323 assert . deepEqual ( testContext . buffer ( ) , [
2424 { type : "moveTo" , x : 165 , y : 160 } ,
25- { type : "arc" , x : 165 , y : 160 }
25+ { type : "arc" , x : 165 , y : 160 , r : 4.5 }
2626 ] ) ;
2727 } ,
2828
@@ -32,9 +32,9 @@ suite.addBatch({
3232 coordinates : [ [ - 63 , 18 ] , [ - 62 , 18 ] , [ - 62 , 17 ] ]
3333 } ) ;
3434 assert . deepEqual ( testContext . buffer ( ) , [
35- { type : "moveTo" , x : 165 , y : 160 } , { type : "arc" , x : 165 , y : 160 } ,
36- { type : "moveTo" , x : 170 , y : 160 } , { type : "arc" , x : 170 , y : 160 } ,
37- { type : "moveTo" , x : 170 , y : 165 } , { type : "arc" , x : 170 , y : 165 }
35+ { type : "moveTo" , x : 165 , y : 160 } , { type : "arc" , x : 165 , y : 160 , r : 4.5 } ,
36+ { type : "moveTo" , x : 170 , y : 160 } , { type : "arc" , x : 170 , y : 160 , r : 4.5 } ,
37+ { type : "moveTo" , x : 170 , y : 165 } , { type : "arc" , x : 170 , y : 165 , r : 4.5 }
3838 ] ) ;
3939 } ,
4040
@@ -75,7 +75,7 @@ suite.addBatch({
7575 geometries : [ { type : "Point" , coordinates : [ 0 , 0 ] } ]
7676 } ) ;
7777 assert . deepEqual ( testContext . buffer ( ) , [
78- { type : "moveTo" , x : 480 , y : 250 } , { type : "arc" , x : 480 , y : 250 }
78+ { type : "moveTo" , x : 480 , y : 250 } , { type : "arc" , x : 480 , y : 250 , r : 4.5 }
7979 ] ) ;
8080 } ,
8181
@@ -85,7 +85,7 @@ suite.addBatch({
8585 features : [ { type : "Feature" , geometry : { type : "Point" , coordinates : [ 0 , 0 ] } } ]
8686 } ) ;
8787 assert . deepEqual ( testContext . buffer ( ) , [
88- { type : "moveTo" , x : 480 , y : 250 } , { type : "arc" , x : 480 , y : 250 }
88+ { type : "moveTo" , x : 480 , y : 250 } , { type : "arc" , x : 480 , y : 250 , r : 4.5 }
8989 ] ) ;
9090 } ,
9191
@@ -123,9 +123,20 @@ suite.addBatch({
123123 assert . strictEqual ( path . pointRadius ( ) , 4.5 ) ;
124124 assert . strictEqual ( path . pointRadius ( radius ) . pointRadius ( ) , radius ) ;
125125 } ,
126- "coerces a constant point radius to a number" : function ( ) {
127- var path = d3 . geo . path ( ) ;
128- assert . strictEqual ( path . pointRadius ( "5" ) . pointRadius ( ) , 5 ) ;
126+ "coerces point radius to a number" : {
127+ "constant" : function ( ) {
128+ var path = d3 . geo . path ( ) ;
129+ assert . strictEqual ( path . pointRadius ( "6" ) . pointRadius ( ) , 6 ) ;
130+ } ,
131+ "function" : function ( path ) {
132+ var radius = path . pointRadius ( ) ;
133+ try {
134+ path . pointRadius ( function ( ) { return "6" ; } ) ( { type : "Point" , coordinates : [ 0 , 0 ] } ) ;
135+ assert . strictEqual ( testContext . buffer ( ) . filter ( function ( d ) { return d . type === "arc" ; } ) [ 0 ] . r , 6 ) ;
136+ } finally {
137+ path . pointRadius ( radius ) ;
138+ }
139+ }
129140 }
130141 } ,
131142
@@ -295,7 +306,7 @@ suite.addBatch({
295306 coordinates : [ - 63 , 18 ]
296307 } ) ;
297308 assert . deepEqual ( testContext . buffer ( ) , [
298- { type : "moveTo" , x : 165 , y : 160 } , { type : "arc" , x : 165 , y : 160 }
309+ { type : "moveTo" , x : 165 , y : 160 } , { type : "arc" , x : 165 , y : 160 , r : 4.5 }
299310 ] ) ;
300311 } ,
301312 "MultiPoint" : function ( path ) {
@@ -304,9 +315,9 @@ suite.addBatch({
304315 coordinates : [ [ - 63 , 18 ] , [ - 62 , 18 ] , [ - 62 , 17 ] ]
305316 } ) ;
306317 assert . deepEqual ( testContext . buffer ( ) , [
307- { type : "moveTo" , x : 165 , y : 160 } , { type : "arc" , x : 165 , y : 160 } ,
308- { type : "moveTo" , x : 170 , y : 160 } , { type : "arc" , x : 170 , y : 160 } ,
309- { type : "moveTo" , x : 170 , y : 165 } , { type : "arc" , x : 170 , y : 165 }
318+ { type : "moveTo" , x : 165 , y : 160 } , { type : "arc" , x : 165 , y : 160 , r : 4.5 } ,
319+ { type : "moveTo" , x : 170 , y : 160 } , { type : "arc" , x : 170 , y : 160 , r : 4.5 } ,
320+ { type : "moveTo" , x : 170 , y : 165 } , { type : "arc" , x : 170 , y : 165 , r : 4.5 }
310321 ] ) ;
311322 } ,
312323 "Polygon" : {
@@ -369,7 +380,7 @@ suite.addBatch({
369380 "Point" : {
370381 "visible" : function ( path ) {
371382 path ( { type : "Point" , coordinates : [ 0 , 0 ] } ) ;
372- assert . deepEqual ( testContext . buffer ( ) , [ { type : "moveTo" , x : 859 , y : 187 } , { type : "arc" , x : 859 , y : 187 } ] ) ;
383+ assert . deepEqual ( testContext . buffer ( ) , [ { type : "moveTo" , x : 859 , y : 187 } , { type : "arc" , x : 859 , y : 187 , r : 4.5 } ] ) ;
373384 } ,
374385 "invisible" : function ( path ) {
375386 path ( { type : "Point" , coordinates : [ - 180 , 0 ] } ) ;
@@ -378,7 +389,7 @@ suite.addBatch({
378389 } ,
379390 "MultiPoint" : function ( path ) {
380391 path ( { type : "MultiPoint" , coordinates : [ [ 0 , 0 ] , [ - 180 , 0 ] ] } ) ;
381- assert . deepEqual ( testContext . buffer ( ) , [ { type : "moveTo" , x : 859 , y : 187 } , { type : "arc" , x : 859 , y : 187 } ] ) ;
392+ assert . deepEqual ( testContext . buffer ( ) , [ { type : "moveTo" , x : 859 , y : 187 } , { type : "arc" , x : 859 , y : 187 , r : 4.5 } ] ) ;
382393 }
383394 } ,
384395 "rotate(-24, -175.5])" : {
@@ -635,7 +646,7 @@ suite.addBatch({
635646 "rotate([0, 0, 0])" : {
636647 "longitudes wrap at ±180°" : function ( path ) {
637648 path ( { type : "Point" , coordinates : [ 180 + 1e-6 , 0 ] } ) ;
638- assert . deepEqual ( testContext . buffer ( ) , [ { type : "moveTo" , x : - 420 , y : 250 } , { type : "arc" , x : - 420 , y : 250 } ] ) ;
649+ assert . deepEqual ( testContext . buffer ( ) , [ { type : "moveTo" , x : - 420 , y : 250 } , { type : "arc" , x : - 420 , y : 250 , r : 4.5 } ] ) ;
639650 }
640651 }
641652 }
@@ -644,7 +655,7 @@ suite.addBatch({
644655var testBuffer = [ ] ;
645656
646657var testContext = {
647- arc : function ( x , y , r , ra , rb ) { testBuffer . push ( { type : "arc" , x : Math . round ( x ) , y : Math . round ( y ) } ) ; } ,
658+ arc : function ( x , y , r , a0 , a1 ) { testBuffer . push ( { type : "arc" , x : Math . round ( x ) , y : Math . round ( y ) , r : r } ) ; } ,
648659 moveTo : function ( x , y ) { testBuffer . push ( { type : "moveTo" , x : Math . round ( x ) , y : Math . round ( y ) } ) ; } ,
649660 lineTo : function ( x , y ) { testBuffer . push ( { type : "lineTo" , x : Math . round ( x ) , y : Math . round ( y ) } ) ; } ,
650661 closePath : function ( ) { testBuffer . push ( { type : "closePath" } ) ; } ,
0 commit comments