@@ -1221,6 +1221,179 @@ def test_block_arity_with_optional_keyword
12211221 end
12221222 end
12231223
1224+ def test_call_node_arity_positional_arguments
1225+ source = <<~SOURCE
1226+ foo(1, 2, 3)
1227+ SOURCE
1228+
1229+ at = location ( chars : 0 ..12 , columns : 0 ..3 , lines : 1 ..1 )
1230+ assert_node ( CallNode , source , at : at ) do |node |
1231+ assert_equal ( 3 , node . arity )
1232+ node
1233+ end
1234+ end
1235+
1236+ def test_call_node_arity_keyword_arguments
1237+ source = <<~SOURCE
1238+ foo(bar, something: 123)
1239+ SOURCE
1240+
1241+ at = location ( chars : 0 ..24 , columns : 0 ..24 , lines : 1 ..1 )
1242+ assert_node ( CallNode , source , at : at ) do |node |
1243+ assert_equal ( 2 , node . arity )
1244+ node
1245+ end
1246+ end
1247+
1248+ def test_call_node_arity_splat_arguments
1249+ source = <<~SOURCE
1250+ foo(*bar)
1251+ SOURCE
1252+
1253+ at = location ( chars : 0 ..9 , columns : 0 ..9 , lines : 1 ..1 )
1254+ assert_node ( CallNode , source , at : at ) do |node |
1255+ assert_equal ( Float ::INFINITY , node . arity )
1256+ node
1257+ end
1258+ end
1259+
1260+ def test_call_node_arity_keyword_rest_arguments
1261+ source = <<~SOURCE
1262+ foo(**bar)
1263+ SOURCE
1264+
1265+ at = location ( chars : 0 ..10 , columns : 0 ..10 , lines : 1 ..1 )
1266+ assert_node ( CallNode , source , at : at ) do |node |
1267+ assert_equal ( Float ::INFINITY , node . arity )
1268+ node
1269+ end
1270+ end
1271+
1272+ guard_version ( "2.7.3" ) do
1273+ def test_call_node_arity_arg_forward_arguments
1274+ source = <<~SOURCE
1275+ def foo(...)
1276+ bar(...)
1277+ end
1278+ SOURCE
1279+
1280+ at = location ( chars : 15 ..23 , columns : 2 ..10 , lines : 2 ..2 )
1281+ assert_node ( CallNode , source , at : at ) do |node |
1282+ call = node . bodystmt . statements . body . first
1283+ assert_equal ( Float ::INFINITY , call . arity )
1284+ call
1285+ end
1286+ end
1287+ end
1288+
1289+ def test_command_arity_positional_arguments
1290+ source = <<~SOURCE
1291+ foo 1, 2, 3
1292+ SOURCE
1293+
1294+ at = location ( chars : 0 ..11 , columns : 0 ..3 , lines : 1 ..1 )
1295+ assert_node ( Command , source , at : at ) do |node |
1296+ assert_equal ( 3 , node . arity )
1297+ node
1298+ end
1299+ end
1300+
1301+ def test_command_arity_keyword_arguments
1302+ source = <<~SOURCE
1303+ foo bar, something: 123
1304+ SOURCE
1305+
1306+ at = location ( chars : 0 ..23 , columns : 0 ..23 , lines : 1 ..1 )
1307+ assert_node ( Command , source , at : at ) do |node |
1308+ assert_equal ( 2 , node . arity )
1309+ node
1310+ end
1311+ end
1312+
1313+ def test_command_arity_splat_arguments
1314+ source = <<~SOURCE
1315+ foo *bar
1316+ SOURCE
1317+
1318+ at = location ( chars : 0 ..8 , columns : 0 ..8 , lines : 1 ..1 )
1319+ assert_node ( Command , source , at : at ) do |node |
1320+ assert_equal ( Float ::INFINITY , node . arity )
1321+ node
1322+ end
1323+ end
1324+
1325+ def test_command_arity_keyword_rest_arguments
1326+ source = <<~SOURCE
1327+ foo **bar
1328+ SOURCE
1329+
1330+ at = location ( chars : 0 ..9 , columns : 0 ..9 , lines : 1 ..1 )
1331+ assert_node ( Command , source , at : at ) do |node |
1332+ assert_equal ( Float ::INFINITY , node . arity )
1333+ node
1334+ end
1335+ end
1336+
1337+ def test_command_call_arity_positional_arguments
1338+ source = <<~SOURCE
1339+ object.foo 1, 2, 3
1340+ SOURCE
1341+
1342+ at = location ( chars : 0 ..18 , columns : 0 ..3 , lines : 1 ..1 )
1343+ assert_node ( CommandCall , source , at : at ) do |node |
1344+ assert_equal ( 3 , node . arity )
1345+ node
1346+ end
1347+ end
1348+
1349+ def test_command_call_arity_keyword_arguments
1350+ source = <<~SOURCE
1351+ object.foo bar, something: 123
1352+ SOURCE
1353+
1354+ at = location ( chars : 0 ..30 , columns : 0 ..30 , lines : 1 ..1 )
1355+ assert_node ( CommandCall , source , at : at ) do |node |
1356+ assert_equal ( 2 , node . arity )
1357+ node
1358+ end
1359+ end
1360+
1361+ def test_command_call_arity_splat_arguments
1362+ source = <<~SOURCE
1363+ object.foo *bar
1364+ SOURCE
1365+
1366+ at = location ( chars : 0 ..15 , columns : 0 ..15 , lines : 1 ..1 )
1367+ assert_node ( CommandCall , source , at : at ) do |node |
1368+ assert_equal ( Float ::INFINITY , node . arity )
1369+ node
1370+ end
1371+ end
1372+
1373+ def test_command_call_arity_keyword_rest_arguments
1374+ source = <<~SOURCE
1375+ object.foo **bar
1376+ SOURCE
1377+
1378+ at = location ( chars : 0 ..16 , columns : 0 ..16 , lines : 1 ..1 )
1379+ assert_node ( CommandCall , source , at : at ) do |node |
1380+ assert_equal ( Float ::INFINITY , node . arity )
1381+ node
1382+ end
1383+ end
1384+
1385+ def test_vcall_arity
1386+ source = <<~SOURCE
1387+ foo
1388+ SOURCE
1389+
1390+ at = location ( chars : 0 ..3 , columns : 0 ..3 , lines : 1 ..1 )
1391+ assert_node ( VCall , source , at : at ) do |node |
1392+ assert_equal ( 0 , node . arity )
1393+ node
1394+ end
1395+ end
1396+
12241397 private
12251398
12261399 def location ( lines : 1 ..1 , chars : 0 ..0 , columns : 0 ..0 )
0 commit comments