LCOV - code coverage report
Current view: top level - modules/esm - gi.js (source / functions) Hit Total Coverage
Test: gjs- Code Coverage Lines: 19 20 95.0 %
Date: 2023-09-17 02:39:54 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 9 10 90.0 %

           Branch data     Line data    Source code
       1                 :            : // SPDX-License-Identifier: MIT OR LGPL-2.0-or-later
       2                 :            : // SPDX-FileCopyrightText: 2020 Evan Welsh <contact@evanwelsh.com>
       3                 :            : 
       4                 :         47 : const gi = import.meta.importSync('gi');
       5                 :            : 
       6                 :         47 : const Gi = {
       7         [ +  + ]:        105 :     require(namespace, version = undefined) {
       8         [ +  - ]:         58 :         if (namespace === 'versions')
       9                 :          0 :             throw new Error('Cannot import namespace "versions", use the version parameter of Gi.require to specify versions.');
      10                 :            : 
      11                 :         58 :         let oldVersion = gi.versions[namespace];
      12         [ +  + ]:         58 :         if (version !== undefined)
      13                 :          4 :             gi.versions[namespace] = version;
      14                 :            : 
      15                 :         58 :         try {
      16                 :         58 :             const module = gi[namespace];
      17                 :            : 
      18 [ +  + ][ +  + ]:         56 :             if (version !== undefined && version !== module.__version__) {
      19                 :          2 :                 throw new Error(`Version ${module.__version__} of GI module ${
      20                 :          1 :                     namespace} already loaded, cannot load version ${version}`);
      21                 :            :             }
      22                 :            : 
      23                 :         55 :             return module;
      24                 :          3 :         } catch (error) {
      25                 :            :             // Roll back change to versions object if import failed
      26                 :          3 :             gi.versions[namespace] = oldVersion;
      27                 :          3 :             throw error;
      28                 :            :         }
      29                 :         55 :     },
      30                 :            : };
      31                 :         47 : Object.freeze(Gi);
      32                 :            : 
      33                 :         47 : export default Gi;

Generated by: LCOV version 1.14