consoleTest.uvue 2.8 KB
Newer Older
杜庆泉's avatar
杜庆泉 已提交
1
<template>
2 3 4 5
  <div>
    <button @click="doLogTest">打印测试</button>
    <text>{{testRet}}</text>
  </div>
杜庆泉's avatar
杜庆泉 已提交
6 7 8 9
</template>

<script>

杜庆泉's avatar
杜庆泉 已提交
10
  import { getLog,logObjectTest,logClassTest,logFunctionTest,logFileTest,logDateTest,logUTSJSONObjectTest } from '../../uni_modules/uts-api-test'
11
 
杜庆泉's avatar
杜庆泉 已提交
12 13 14

	export default {
		data() {
15 16 17
			return {
        testRet:''
      }
杜庆泉's avatar
杜庆泉 已提交
18 19 20
		},
		methods: {
			
21 22 23 24 25 26 27 28 29 30 31
			doLogTest() {
        
        if(getLog("") != '{"type":"string","value":""}'){
          this.testRet = "测试失败"
          return;
        }
        
        if(getLog("字符串打印测试") != '{"type":"string","value":"字符串打印测试"}'){
          this.testRet = "测试失败"
          return;
        }
杜庆泉's avatar
杜庆泉 已提交
32
        if(getLog(2023) != '{"subType":"number","type":"number","value":"2023"}'){
33 34 35 36 37 38 39 40
          this.testRet = "测试失败"
          return;
        }
        // console.log(getLog(2023.0))
        // if(getLog(2023.0) != '{"type":"number","value":"2023"}'){
        //   this.testRet = "测试失败"
        //   return;
        // }
杜庆泉's avatar
杜庆泉 已提交
41
        if(getLog(2023.002 as number) != '{"subType":"number","type":"number","value":"2023.002"}'){
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
          this.testRet = "测试失败"
          return;
        }
        
        if(logObjectTest() != '{"className":"uts.sdk.modules.utsApiTest.ParamOptions","subType":"object","__$originalPosition":"","type":"object","value":{"methods":[],"properties":[{"name":"array","subType":"array","className":"io.dcloud.uts.UTSArray","type":"object","value":{"properties":[{"name":0,"type":"string","value":"1"},{"name":1,"type":"string","value":"2"},{"name":2,"type":"string","value":"3"}]}},{"name":"title","type":"string","value":"logObjectTest"}]}}'){
          this.testRet = "测试失败"
          return;
        }
        
        if(logFunctionTest() != '{"parameter":[],"type":"function"}'){
          this.testRet = "测试失败"
          return;
        }
        
        if(logClassTest() != '{"className":"uts.sdk.modules.utsApiTest.C","subType":"object","__$originalPosition":"","type":"object","value":{"methods":[],"properties":[{"name":"name","type":"string","value":"ccc"},{"parameter":["string"],"name":"sayBye","type":"function"}]}}'){
          this.testRet = "测试失败"
          return;
        }
        /**
         * uvue 和 vue 因为 java 版本不同,所以这里的打印格式可能存在差异
         */
        if(logFileTest() != '{"className":"java.io.File","subType":"object","type":"object","value":{"methods":[],"properties":[]}}'){
          this.testRet = "测试失败"
          return;
        }
        
        if(logDateTest() != '{"className":"io.dcloud.uts.Date","subType":"date","type":"object","value":"Sat Aug 08 1998 08:00:00 GMT+0800"}'){
          this.testRet = "测试失败"
          return;
        }
        
        this.testRet = "测试完成"
        
			}
杜庆泉's avatar
杜庆泉 已提交
76 77 78 79 80 81 82

		}
	}
</script>

<style>
</style>