instanceTest.vue 1.6 KB
Newer Older
杜庆泉's avatar
杜庆泉 已提交
1
<template>
杜庆泉's avatar
杜庆泉 已提交
2 3 4
  <div>
    {{ret}}
    <button @click="instanceCreate">多实例创建测试</button>
杜庆泉's avatar
杜庆泉 已提交
5
    <button @click="defaultValueTest">默认值测试</button>
杜庆泉's avatar
杜庆泉 已提交
6
  </div>
杜庆泉's avatar
杜庆泉 已提交
7 8 9 10 11 12 13 14
	
</template>

<script>
	import {
		User
	} from '@/uni_modules/uts-advance'

杜庆泉's avatar
杜庆泉 已提交
15 16 17 18 19 20
  import {
      Scan, 
      Scan1, 
      Scan2, 
      myClass
  } from "@/uni_modules/uts-syntaxcase";
杜庆泉's avatar
杜庆泉 已提交
21 22 23 24 25 26 27 28 29

	export default {
		data() {
			return {
				ret:''
			}
		},
		methods: {
			
杜庆泉's avatar
杜庆泉 已提交
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
      defaultValueTest() {
        const myClassInit = new myClass();
        // 默认值测试
        if(Scan() != 60000){
          this.ret = "测试失败1"
        }
        if(Scan(100) != 100){
          this.ret = "测试失败2"
        }
        if(Scan1() != null){
          this.ret = "测试失败3"
        }
        if(Scan1(100) != 100){
          this.ret = "测试失败4"
        }
        let ret5 = Scan2()
        if(ret5 != "null"){
          console.log(ret5)
          this.ret = "测试失败5"
        }
        if(Scan2(100) != 100){
          this.ret = "测试失败6"
        }
        if(myClassInit.to('123') != 123){
          this.ret = "测试失败7"
        }
      },
      
杜庆泉's avatar
杜庆泉 已提交
58 59 60 61 62
			instanceCreate() {
				
				const user1 = new User("张三", 20);
				const user2 = new User("李四", 30);  
				const user3 = new User("王五", 40);  
杜庆泉's avatar
杜庆泉 已提交
63 64 65
				
				let userText1 = user1.describeSelf() 
				let userText2 = user2.describeSelf()   
杜庆泉's avatar
杜庆泉 已提交
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
				let userText3 = user3.describeSelf()  

				
				if(userText1 == userText2 || userText1 == userText3 || userText2 == userText3){
					this.ret = '测试未通过'
				}else{
					this.ret = '测试通过'
				}
				
			}

			
		}
	}
</script>

<style>
</style>