| 1 |
import QtQuick 2.0 |
| 2 |
import io.thp.pyotherside 1.2 |
| 3 |
|
| 4 |
// Test if PyOtherSide correctly reports JS errors happening in callbacks |
| 5 |
// in signal error(string traceback) for both imports and function calls. |
| 6 |
|
| 7 |
Python { |
| 8 |
property var tests: ([]) |
| 9 |
|
| 10 |
function test_next() { |
| 11 |
if (tests.length) { |
| 12 |
tests.pop()(); |
| 13 |
} else { |
| 14 |
console.log('Tests done'); |
| 15 |
Qt.quit(); |
| 16 |
} |
| 17 |
} |
| 18 |
|
| 19 |
Component.onCompleted: { |
| 20 |
tests.unshift(function () { |
| 21 |
console.log('Expecting ReferenceError for "invalid" on import'); |
| 22 |
importModule('os', function (success) { |
| 23 |
invalid; |
| 24 |
}); |
| 25 |
}); |
| 26 |
tests.unshift(function() { |
| 27 |
console.log('Expecting TypeError for "lock" property'); |
| 28 |
call('os.getcwd', [], function (result) { |
| 29 |
console.lock(result); |
| 30 |
}); |
| 31 |
}); |
| 32 |
test_next(); |
| 33 |
} |
| 34 |
|
| 35 |
onError: { |
| 36 |
// Remove full path to .qml file |
| 37 |
var msg = traceback.replace(Qt.resolvedUrl('.'), ''); |
| 38 |
console.log('Got error: ' + msg); |
| 39 |
test_next(); |
| 40 |
} |
| 41 |
} |