mirror of
https://github.com/swc-project/swc.git
synced 2024-11-23 17:54:15 +03:00
test(swc): Add tests (#3435)
This commit is contained in:
parent
6c9b311881
commit
9e4cea017c
18
crates/swc/tests/fixture/issue-3417/1/input/.swcrc
Normal file
18
crates/swc/tests/fixture/issue-3417/1/input/.swcrc
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"jsc": {
|
||||
"parser": {
|
||||
"syntax": "typescript",
|
||||
"tsx": false
|
||||
},
|
||||
"target": "es5",
|
||||
"loose": false,
|
||||
"minify": {
|
||||
"compress": false,
|
||||
"mangle": false
|
||||
}
|
||||
},
|
||||
"module": {
|
||||
"type": "es6"
|
||||
},
|
||||
"minify": false
|
||||
}
|
59
crates/swc/tests/fixture/issue-3417/1/input/index.ts
Normal file
59
crates/swc/tests/fixture/issue-3417/1/input/index.ts
Normal file
@ -0,0 +1,59 @@
|
||||
export function selectRooms(building: Building) {
|
||||
const roomsByRow: { [key: string]: [string, string, string, string] } = {};
|
||||
|
||||
const { rooms, walls, levels, roomsByLevel } = building;
|
||||
|
||||
function getRoomFloorMaterial(_: Room) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (const level of levels) {
|
||||
const levelId = level.id;
|
||||
const levelRooms = roomsOnLevel(levelId, rooms, roomsByLevel);
|
||||
|
||||
const sortedRooms: Room[] = [];
|
||||
for (const room of levelRooms) {
|
||||
sortedRooms.push(room);
|
||||
}
|
||||
|
||||
sortedRooms.sort((a, b) => a + b);
|
||||
|
||||
const visitedRooms: { [roomId: string]: boolean } = {};
|
||||
|
||||
for (const room of sortedRooms) {
|
||||
if (visitedRooms[room.id]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const connectedRoomSet: RoomSet = [];
|
||||
const roomPrettyName = formatRoomName(room);
|
||||
const roomFloorMat = getRoomFloorMaterial(room);
|
||||
|
||||
groupRoomsOnLevel(
|
||||
room,
|
||||
walls,
|
||||
(_, endRoom, wall) =>
|
||||
wall.wallType === WallType.VOID &&
|
||||
roomPrettyName.toUpperCase() ===
|
||||
formatRoomName(endRoom).toUpperCase() &&
|
||||
roomFloorMat === getRoomFloorMaterial(endRoom),
|
||||
(room) => connectedRoomSet.push(room),
|
||||
visitedRooms
|
||||
);
|
||||
|
||||
let areaTotal = 0;
|
||||
for (const setRoom of connectedRoomSet) {
|
||||
const wallIndex = walls[levelId].wallIndex;
|
||||
}
|
||||
|
||||
areaTotal = Math.round(areaTotal) / 10;
|
||||
roomsByRow[room.id] = [
|
||||
roomPrettyName,
|
||||
`${areaTotal} SF`,
|
||||
roomFloorMat,
|
||||
FLOOR_MAPPING[levelId],
|
||||
];
|
||||
}
|
||||
}
|
||||
return { rows: Object.values(roomsByRow) };
|
||||
}
|
119
crates/swc/tests/fixture/issue-3417/1/output/index.ts
Normal file
119
crates/swc/tests/fixture/issue-3417/1/output/index.ts
Normal file
@ -0,0 +1,119 @@
|
||||
export function selectRooms(building) {
|
||||
var getRoomFloorMaterial = function getRoomFloorMaterial(_) {
|
||||
return null;
|
||||
};
|
||||
var roomsByRow = {};
|
||||
var rooms = building.rooms, walls = building.walls, levels = building.levels, roomsByLevel = building.roomsByLevel;
|
||||
var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = undefined;
|
||||
try {
|
||||
var _loop1 = function(_iterator3, _step3) {
|
||||
var level = _step3.value;
|
||||
var levelId = level.id;
|
||||
var levelRooms = roomsOnLevel(levelId, rooms, roomsByLevel);
|
||||
var sortedRooms = [];
|
||||
var _iteratorNormalCompletion3 = true, _didIteratorError3 = false, _iteratorError3 = undefined;
|
||||
try {
|
||||
for(var _iterator1 = levelRooms[Symbol.iterator](), _step1; !(_iteratorNormalCompletion3 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion3 = true){
|
||||
var room = _step1.value;
|
||||
sortedRooms.push(room);
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError3 = true;
|
||||
_iteratorError3 = err;
|
||||
} finally{
|
||||
try {
|
||||
if (!_iteratorNormalCompletion3 && _iterator1.return != null) {
|
||||
_iterator1.return();
|
||||
}
|
||||
} finally{
|
||||
if (_didIteratorError3) {
|
||||
throw _iteratorError3;
|
||||
}
|
||||
}
|
||||
}
|
||||
sortedRooms.sort(function(a, b) {
|
||||
return a + b;
|
||||
});
|
||||
var visitedRooms = {};
|
||||
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
||||
try {
|
||||
var _loop = function(_iterator2, _step2) {
|
||||
var room1 = _step2.value;
|
||||
if (visitedRooms[room1.id]) {
|
||||
return "continue";
|
||||
}
|
||||
var connectedRoomSet = [];
|
||||
var roomPrettyName = formatRoomName(room1);
|
||||
var roomFloorMat = getRoomFloorMaterial(room1);
|
||||
groupRoomsOnLevel(room1, walls, function(_, endRoom, wall) {
|
||||
return wall.wallType === WallType.VOID && roomPrettyName.toUpperCase() === formatRoomName(endRoom).toUpperCase() && roomFloorMat === getRoomFloorMaterial(endRoom);
|
||||
}, function(room) {
|
||||
return connectedRoomSet.push(room);
|
||||
}, visitedRooms);
|
||||
var areaTotal = 0;
|
||||
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
||||
try {
|
||||
for(var _iterator = connectedRoomSet[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
||||
var setRoom = _step.value;
|
||||
var wallIndex = walls[levelId].wallIndex;
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally{
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally{
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
areaTotal = Math.round(areaTotal) / 10;
|
||||
roomsByRow[room1.id] = [
|
||||
roomPrettyName,
|
||||
"".concat(areaTotal, " SF"),
|
||||
roomFloorMat,
|
||||
FLOOR_MAPPING[levelId],
|
||||
];
|
||||
};
|
||||
for(var _iterator2 = sortedRooms[Symbol.iterator](), _step2; !(_iteratorNormalCompletion1 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion1 = true){
|
||||
var _ret = _loop(_iterator2, _step2);
|
||||
if (_ret === "continue") continue;
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError1 = true;
|
||||
_iteratorError1 = err;
|
||||
} finally{
|
||||
try {
|
||||
if (!_iteratorNormalCompletion1 && _iterator2.return != null) {
|
||||
_iterator2.return();
|
||||
}
|
||||
} finally{
|
||||
if (_didIteratorError1) {
|
||||
throw _iteratorError1;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
for(var _iterator3 = levels[Symbol.iterator](), _step3; !(_iteratorNormalCompletion2 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion2 = true)_loop1(_iterator3, _step3);
|
||||
} catch (err) {
|
||||
_didIteratorError2 = true;
|
||||
_iteratorError2 = err;
|
||||
} finally{
|
||||
try {
|
||||
if (!_iteratorNormalCompletion2 && _iterator3.return != null) {
|
||||
_iterator3.return();
|
||||
}
|
||||
} finally{
|
||||
if (_didIteratorError2) {
|
||||
throw _iteratorError2;
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
rows: Object.values(roomsByRow)
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user