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

             Branch data     Line data    Source code
       1                 :          48 : // SPDX-License-Identifier: MIT OR LGPL-2.0-or-later
       2                 :             : // SPDX-FileCopyrightText: 2020 Evan Welsh <contact@evanwelsh.com>
       3                 :             : 
       4                 :          48 : const gi = import.meta.importSync('gi');
       5                 :             : 
       6                 :          48 : const Gi = {
       7         [ +  + ]:         107 :     require(namespace, version = undefined) {
       8         [ +  - ]:          59 :         if (namespace === 'versions')
       9                 :           0 :             throw new Error('Cannot import namespace "versions", use the version parameter of Gi.require to specify versions.');
      10                 :             : 
      11                 :          59 :         let oldVersion = gi.versions[namespace];
      12         [ +  + ]:          59 :         if (version !== undefined)
      13                 :           4 :             gi.versions[namespace] = version;
      14                 :             : 
      15                 :          59 :         try {
      16                 :          59 :             const module = gi[namespace];
      17                 :             : 
      18 [ +  + ][ +  + ]:          57 :             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                 :          56 :             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                 :          56 :     },
      30                 :             : };
      31                 :          48 : Object.freeze(Gi);
      32                 :             : 
      33                 :          48 : export default Gi;
        

Generated by: LCOV version 2.0-1