|
1336 | 1336 | it(title) {run_compact(params)} |
1337 | 1337 | end |
1338 | 1338 | end |
| 1339 | + |
| 1340 | + context "compact IRI selection" do |
| 1341 | + { |
| 1342 | + "does not compact using expanded term" => { |
| 1343 | + input: %({"http://example.org/foo": "term"}), |
| 1344 | + context: %({"ex": {"@id": "http://example.org/"}}), |
| 1345 | + output: %({ |
| 1346 | + "@context": {"ex": {"@id": "http://example.org/"}}, |
| 1347 | + "http://example.org/foo": "term" |
| 1348 | + }) |
| 1349 | + }, |
| 1350 | + "does not compact using simple term not ending in gen-delim" => { |
| 1351 | + input: %({"http://example.org/foo": "term"}), |
| 1352 | + context: %({"ex": "http://example.org/f"}), |
| 1353 | + output: %({ |
| 1354 | + "@context": {"ex": "http://example.org/f"}, |
| 1355 | + "http://example.org/foo": "term" |
| 1356 | + }) |
| 1357 | + }, |
| 1358 | + "compacts using simple term ending in gen-delim ('/')" => { |
| 1359 | + input: %({"http://example.org/foo": "term"}), |
| 1360 | + context: %({"ex": "http://example.org/"}), |
| 1361 | + output: %({ |
| 1362 | + "@context": {"ex": "http://example.org/"}, |
| 1363 | + "ex:foo": "term" |
| 1364 | + }) |
| 1365 | + }, |
| 1366 | + "compacts using simple term ending in gen-delim (':')" => { |
| 1367 | + input: %({"http://example.org/foo:bar": "term"}), |
| 1368 | + context: %({"ex": "http://example.org/foo:"}), |
| 1369 | + output: %({ |
| 1370 | + "@context": {"ex": "http://example.org/foo:"}, |
| 1371 | + "ex:bar": "term" |
| 1372 | + }) |
| 1373 | + }, |
| 1374 | + "compacts using simple term ending in gen-delim ('?')" => { |
| 1375 | + input: %({"http://example.org/foo?bar": "term"}), |
| 1376 | + context: %({"ex": "http://example.org/foo?"}), |
| 1377 | + output: %({ |
| 1378 | + "@context": {"ex": "http://example.org/foo?"}, |
| 1379 | + "ex:bar": "term" |
| 1380 | + }) |
| 1381 | + }, |
| 1382 | + "compacts using simple term ending in gen-delim ('#')" => { |
| 1383 | + input: %({"http://example.org/foo#bar": "term"}), |
| 1384 | + context: %({"ex": "http://example.org/foo#"}), |
| 1385 | + output: %({ |
| 1386 | + "@context": {"ex": "http://example.org/foo#"}, |
| 1387 | + "ex:bar": "term" |
| 1388 | + }) |
| 1389 | + }, |
| 1390 | + "compacts using simple term ending in gen-delim ('[')" => { |
| 1391 | + input: %({"http://example.org/foo[bar": "term"}), |
| 1392 | + context: %({"ex": "http://example.org/foo["}), |
| 1393 | + output: %({ |
| 1394 | + "@context": {"ex": "http://example.org/foo["}, |
| 1395 | + "ex:bar": "term" |
| 1396 | + }) |
| 1397 | + }, |
| 1398 | + "compacts using simple term ending in gen-delim (']')" => { |
| 1399 | + input: %({"http://example.org/foo]bar": "term"}), |
| 1400 | + context: %({"ex": "http://example.org/foo]"}), |
| 1401 | + output: %({ |
| 1402 | + "@context": {"ex": "http://example.org/foo]"}, |
| 1403 | + "ex:bar": "term" |
| 1404 | + }) |
| 1405 | + }, |
| 1406 | + "compacts using simple term ending in gen-delim ('@')" => { |
| 1407 | + input: %({"http://example.org/foo@bar": "term"}), |
| 1408 | + context: %({"ex": "http://example.org/foo@"}), |
| 1409 | + output: %({ |
| 1410 | + "@context": {"ex": "http://example.org/foo@"}, |
| 1411 | + "ex:bar": "term" |
| 1412 | + }) |
| 1413 | + }, |
| 1414 | + "prefers compacting using simple term ending ':' in 1.1" => { |
| 1415 | + input: %({"http://example.org/foo/bar": "term"}), |
| 1416 | + context: %({"ex": "http://example.org/foo/", "xe:": "http://example.org/foo/"}), |
| 1417 | + output: %({ |
| 1418 | + "@context": {"ex": "http://example.org/foo/", "xe:": "http://example.org/foo/"}, |
| 1419 | + "xe:bar": "term" |
| 1420 | + }), |
| 1421 | + processingMode: 'json-ld-1.1' |
| 1422 | + }, |
| 1423 | + }.each do |title, params| |
| 1424 | + it(title) {run_compact(params)} |
| 1425 | + end |
| 1426 | + end |
1339 | 1427 | end |
1340 | 1428 |
|
1341 | 1429 | def run_compact(params) |
|
0 commit comments